我的目标是不映射/ {任何路径}和*。html的映射到一个servlet/*。例如:@RequestMapping欢迎文件
map:
/foo
/foobar/
/bar.html
/foo/bar.html
don't map:
/foo.js
/bar.pdf
为了做到这一点,我有一个servlet和欢迎文件映射像这样:
的web.xml:
<servlet-mapping>
<servlet-name>someServlet</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
,并在控制器,我有
@RequestMapping(value="/index.html", method=RequestMethod.GET)
public ModelAndView showPage(HttpServletRequest request){
...
}
这将不起作用 - 该小服务程序不会在/test
上触发。不过,我发现,如果我在/test/index.html
创建一个空白文件,然后将其确实工作 - 我假设默认的servlet以某种方式通过寻找index.html的帮助。
不幸的是,我不能依靠静态文件。有没有什么办法可以让这个映射工作,而空白的文件,黑客和没有映射/ *到servlet?
http://stackoverflow.com/questions/7415084/spring-welcome-file-list-correct-mapping – 2012-10-24 13:40:08