springmvc框架问题
网页上添加部门名称出现这个问题No mapping found for HTTP request with URI [/web/addOrUpdateDepart.do] in DispatcherServlet with name 'springmvc' 求大神解决
web.xml
<web-app>
<display-name>Archetype Created Web Application</display-name>
<filter>
<filter-name>EncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>EncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 读取spring的配置文件 -->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
<!-- 1,创建数据源 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/crm?useUnicode=true&characterEncoding=utf8"></property>
<property name="user" value="root"></property>
<property name="password" value="123"></property>
</bean>
<!-- 2,创建SessionFactory:Spring提供 -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<!-- 2.1替换数据源 -->
<property name="dataSource" ref="dataSource"></property>
<!-- 2.2替换hibernate的属性 -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<!-- 2.3替换注册实体部分 -->
<property name="mappingResources">
<array>
<value>com/ym/pojo/CrmClass.hbm.xml</value>
<value>com/ym/pojo/CrmCourseType.hbm.xml</value>
<value>com/ym/pojo/CrmDepartment.hbm.xml</value>
<value>com/ym/pojo/CrmFollow.hbm.xml</value>
<value>com/ym/pojo/CrmGraduate.hbm.xml</value>
<value>com/ym/pojo/CrmPost.hbm.xml</value>
<value>com/ym/pojo/CrmRefer.hbm.xml</value>
<value>com/ym/pojo/CrmRunoff.hbm.xml</value>
<value>com/ym/pojo/CrmStaff.hbm.xml</value>
<value>com/ym/pojo/CrmStation.hbm.xml</value>
<value>com/ym/pojo/CrmStudent.hbm.xml</value>
</array>
</property>
</bean>
applicationcontext。xml
<!-- 3,创建持久层DAO对象 -->
<bean id="crmDepartmentDAO" class="com.ym.dao.CrmDepartmentDAOImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 4,创建服务层对象 -->
<bean id="crmDepartmentService" class="com.ym.service.CrmDepartmentServiceImpl">
<property name="crmDepartmentDAO" ref="crmDepartmentDAO"></property>
</bean>
<!-- 5,创建事务通知对象 -->
<bean id="txManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
<property name="dataSource" ref="dataSource"></property>
</bean>
<!-- 6,事务通知切面 -->
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="find*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 7,AOP编程 -->
<aop:config>
<aop:pointcut expression="execution(* com.ym.service.*.*(..))" id="mypoint"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="mypoint"/>
</aop:config>
<!-- 8,整合表现层 -->
<!-- 8.1映射器和适配器 -->
<mvc:annotation-driven></mvc:annotation-driven>
<!-- 8.2视图解析器 -->
<!-- 配置视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"></bean>
<!-- 8.3开启扫描 -->
<!-- 扫描action -->
<context:component-scan base-package="com.ym.action"></context:component-scan>
com.ym.action CrmDepartmentAction.java
import org.springframework.web.servlet.ModelAndView;
import com.ym.pojo.CrmDepartment;
import com.ym.service.CrmDepartmentService;
@Controller
public class CrmDepartmentAction {
//依赖服务层
@Autowired
@Qualifier("crmDepartmentService")
private CrmDepartmentService crmDepartmentService;
public void setCrmDepartmentService(CrmDepartmentService crmDepartmentService) {
this.crmDepartmentService = crmDepartmentService;
}
@RequestMapping("/addDepart.do")
public ModelAndView addDepart(HttpServletRequest request,HttpServletResponse response){
ModelAndView mv = new ModelAndView();
//得到页面上的数据:
String depName = request.getParameter("depName");
//添加
CrmDepartment pojo = new CrmDepartment();
pojo.setDepName(depName);
crmDepartmentService.addCrmDepartment(pojo);
mv.setViewName("/pages/login.jsp");
return mv;
}