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

在搭建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.

翻译不清楚,留用。

你可能感兴趣的:(学习心得)