Sunday 15 January 2012

java - How to avoid matching paths that don't have a slash with servlet-mappings? -


I'm trying to set up a servlet so that no one is going to / foo / * Also, go to my foo servlet, except for requests such as bar to go to / foo / bar / * , though request me < Code> / foo / bar> want to go to Foo servlet, not the bar one. Is there any way to do this with web-url in url-pattern?

My Mapping:

  & lt; Servlet-mapping & gt; & Lt; Servlet-name & gt; Bar & lt; / Servlet-name & gt; & Lt; URL pattern & gt; / Foo / bar / * & lt; / URL pattern & gt; & Lt; / Servlet-mapping & gt; & Lt; Servlet-mapping & gt; & Lt; Servlet-name & gt; Foo & lt; / Servlet-name & gt; & Lt; URL pattern & gt; / Foo / * & lt; / URL pattern & gt; & Lt; / Servlet-mapping & gt;   

I have tried to remove the stars and try some other methods, but the only way I can see this is to do this / foo / bar , though it seems that there should be a better way.

If you are using the servlet specification, you are equal to V2.5 or above Several url-pattern elements can be provided for servlet-mapping :

  & lt; Servlet-mapping & gt; & Lt; Servlet-name & gt; Foo & lt; / Servlet-name & gt; & Lt; URL pattern & gt; / Foo / * & lt; / URL pattern & gt; & Lt; URL pattern & gt; / Foo / bar & lt; / URL pattern & gt; & Lt; / Servlet-mapping & gt;  

No comments:

Post a Comment