简体   繁体   中英

Configuring Spring to directory structure rather than *.html or other pattern

I want my spring application to access url like http://myapplication.com/app1/feature/ rather than http://myapplication.com/app1/feature.html So basically how should I configure. My Current config is below it works with *.html web.xml

web.xml and it gives 404 error it I do map it to * .* etc

and it gives 404 error it I do map it to * .* etc

The servlet spec is very strict about what's allowed in a url-pattern . You're probably looking for /* , which will direct all requests to the DispatcherServlet , regardless of the path. Then it's up to you to define what happens.

For reference, "Specification of Mappings" (12.2) allows the following patterns:

  • A string beginning with a '/' character and ending with a '/*' suffix is used for path mapping.
  • A string beginning with a '*.' prefix is used as an extension mapping.
  • The empty string ("") is a special URL pattern that exactly maps to the application's context root, ie, requests of the form http://host:port/<contextroot>/ . In this case the path info is '/' and the servlet path and context path is empty string (““).
  • A string containing only the '/' character indicates the "default" servlet of the application. In this case the servlet path is the request URI minus the context path and the path info is null.
  • All other strings are used for exact matches only

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM