您的位置:首页 > 理论基础 > 计算机网络

springmvc--无法找到视图PageNotFound.noHandlerFound No mapping found for HTTP request

2017-08-27 15:12 302 查看
在搭建SSM框架的过程中,我首先搭建SpringMVC框架,如何搭建,此处略。刚开始没有问题,springMVC搭建成功,运行、测试也没有问题,之后在集成mybatis和Spring的时候,可能不小心改了web.xml中的配置,报404。搞了好久,最后偶然发现一篇文档:https://stackoverflow.com/questions/41577234/why-does-spring-mvc-respond-with-a-404-and-report-no-mapping-found-for-http-req
  里面解决方法是将web.xml文件中的配置

改成

原因,大概意思就是因为  /*  斜杠+星号表示匹配所有请求路径,优先级比  /   斜杆   要高,而InternalResourceViewResolver的处理方式见这位老兄的文章:http://blog.csdn.net/zmx729618/article/details/51554762,因此,会出现一些问题:

No mapping found for HTTP request with URI 
[/Example/WEB-INF/jsps/example-view-name.jsp]
 in 
DispatcherServlet
 with
name 'dispatcher'

Because the 
DispatcherServlet
 is
mapped to 
/*
 and 
/*
 matches
everything (except exact matches, which have higher priority), the 
DispatcherServlet
 would
be chosen to handle the 
forward
 from
the 
JstlView
 (returned
by the 
InternalResourceViewResolver
). In
almost every case, the 
DispatcherServlet
 will
not be configured to handle such a request.

Instead, in this simplistic case, you should register the 
DispatcherServlet
 to 
/
,
marking it as the default servlet. The default servlet is the last match for a request. This will allow your typical servlet container to chose an internal Servlet implementation, mapped to 
*.jsp
,
to handle the JSP resource (for example, Tomcat has 
JspServlet
),
before trying with the default servlet.

翻译不清楚,留用。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐