No mapping found for HTTP request with URI [/.../...] in DispatcherServlet
程序员文章站
2022-07-15 13:11:58
...
在springmvc中,出现No mapping found for HTTP request with URI [/…/…]in DispatcherServlet.
可以从以下几方面排除错误
1.检查@RequestMapping注解的格式
如:
<body>
<a href="account/finAll">测试</a>
</body>
则对应的实体类中的@RequestMapping的属性值必须与超链接的href属性对应。切记在href属性值的最前面务必不要加 “/” 。
@Controller
@RequestMapping("/account")
public class AccountController {
@RequestMapping("/finAll")
public String findAll(){
System.out.println("表现层查询所有用户");
return "list";
}
}
2.检查Controller是否注入bean到容器里。仔细检查全限定类名是否正确。
<!--开启注解扫描,只扫描Controller-->
<context:component-scan base-package="cn.itcast">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
如果需要开启注解扫描的限定范围。则要注意不要把包引错了。
<!--正确的是-->
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
<!--错误的是-->
<context:include-filter type="annotation" expression="org.springframework.web.servlet.mvc.Controller"/>
3.检查视图解析器配置,所访问的文件在所目录,必定要与prefix的值相符。
<bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!--JSP文件所在目录-->
<property name="prefix" value="/WEB-INF/跳转页面的包名/"/>
<!--文件后缀名-->
<property name="suffix" value=".jsp"/>
</bean>
推荐阅读
-
No mapping found for HTTP request with URI [/springmvc-1/springmvc/testParamsAndHeaders] in Dispatch
-
vue+No mapping found for HTTP request with URI [*//**] in DispatcherServlet with name ‘springMvc‘
-
异常记录二:寻求解决异常 !No mapping found for HTTP request with URI
-
如何解决“ No mapping found for HTTP request with URI [XXX] in DispatcherServlet with name 'XXX' ”
-
警告: No mapping found for HTTP request with URI [/springmvc-01/helloworld] in DispatcherServlet with
-
No mapping found for HTTP request with URI [/xxx/xxx] in DispatcherServlet with name 'xxx'
-
No mapping found for HTTP request with URI [...] in DispatcherServlet with name ‘DispatcherServlet‘
-
No mapping found for HTTP request with URI [***.html] in DispatcherServlet with name "***"
-
No mapping found for HTTP request with URI [/HelloWeb/] in DispatcherServlet with name 'HelloWeb...
-
No mapping found for HTTP request with URI [/app17a/] in DispatcherServlet with name 'springmvc'解决方法