解决SSM:No mapping found for HTTP request with URI [路径] in DispatcherServlet with name 'dispatcherServ

No mapping found for HTTP request with URI [路径] in DispatcherServlet with name 'dispatcherServlet

跳转过程:
在这里插入图片描述

  1. index.jsp 里面跳转到 “/emps”

在这里插入图片描述

  1. 来到controller控制器,返回list

在这里插入图片描述
上面是web.xml配置的springmvc前端控制器

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
 
		<!-- springmvc配置文件,包含网站的跳转逻辑的控制 -->
		<context:component-scan base-package="com.zzf" use-default-filters="false">
			<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
		</context:component-scan>
		
		<!-- 配置视图解析器 -->
		<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
			<property name="prefix" value="/WEB-INF/views/"></property>
			<property name="suffix" value=".jsp"></property>
		</bean>
		
		<!-- 两个标准配置 -->
		<mvc:default-servlet-handler/>
		<mvc:annotation-driven/>
</beans>

上面是dispatcherServelt-servlet.xml文件

<mvc:default-servlet-handler/>
<mvc:annotation-driven/>这两个配置很重要

我的错误是文件名字有问题,在上面的前端控制器中,进入到dispatcherServelt-servlet.xml
在这里插入图片描述

然后看/WEB-INF/views/list.jsp

发布了33 篇原创文章 · 获赞 15 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_35764460/article/details/87298348