Url pattern for exact matches on url without extension

How would you make it /url

work but /url.html

or /url.jsp

fail? I would like to customize my template to only accept exact matches that have no extension.

Currently in web.xml I am using

<servlet-mapping>
   <servlet-name>DispatchServlet</servlet-name>
   <url-pattern>/</url-pattern>
</servlet-mapping>

      

and on my controllers i use

@RequestMapping(value = "/url", method = RequestMethod.GET)

      

but this allows any extension to be mapped to my controllers as long as the "url" is in the requested path. I would like to see extensions or incorrectly added characters fail. Is there a way to do this without parsing the url string programmatically for each controller?

+3


source to share





All Articles