项目使用restful风格,默认全局拦截/请求,如果再web.xml里面<welcome-file-list>
直接配置index.jsp/index.html会被当成静态资源拦截,如何把@RequestMapping设置成首页,解决方案:
@Controller
@RequestMapping("/router")
public class RouterController {
/**
* 管理员登陆
* @return
*/
@RequestMapping(value = "/login", method = RequestMethod.GET)
public String admin(){
return "admin/login";
}
在web.xml添加
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/router/login</url-pattern>
</servlet-mapping>
<!--首页-->
<welcome-file-list>
<!--这里没有"/"-->
<welcome-file>router/login</welcome-file>
</welcome-file-list>