spring mvc找不到controller

以前运行好好的,不过现在怎么都运行不了,controller进不去,打开网页就是404,很郁闷,调试了十多天还是一样的,找不到问题

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>acp</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:application.xml</param-value>
  </context-param>
  <context-param>
    <param-name>webAppRootKey</param-name>
    <param-value>springmvc.root</param-value>
  </context-param>
  <filter>
    <filter-name>SpringEncodingFilter</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>SpringEncodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <servlet>
    <servlet-name>dispatcherServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:springmvc/spring-mvc.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <error-page>
    <error-code>404</error-code>
    <location>/WEB-INF/errorpage/404.jsp</location>
  </error-page>
  <error-page>
    <error-code>405</error-code>
    <location>/WEB-INF/errorpage/405.jsp</location>
  </error-page>
  <error-page>
    <error-code>500</error-code>
    <location>/WEB-INF/errorpage/500.jsp</location>
  </error-page>
</web-app>

application.xml


<?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:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="  
           http://www.springframework.org/schema/beans  
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
           http://www.springframework.org/schema/aop  
           http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
           http://www.springframework.org/schema/context  
           http://www.springframework.org/schema/context/spring-context-3.0.xsd">

     <!-- 引入jdbc配置文件 -->  
     <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
               <value>classpath:properties/*.properties</value>
                <!--要是有多个配置文件,只需在这里继续添加即可 -->
            </list>
        </property>
    </bean>



    <!-- 配置数据源 -->
    <bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <!-- 不使用properties来配置 -->
        <!-- <property name="driverClassName" value="com.mysql.jdbc.Driver" /> 
            <property name="url" value="jdbc:mysql://localhost:3306/learning" /> 
            <property name="username" value="root" /> 
            <property name="password" value="christmas258@" /> -->
       <!-- 使用properties来配置 -->
        <property name="driverClassName">
            <value>${jdbc_driverClassName}</value>
        </property>
        <property name="url">
            <value>${jdbc_url}</value>
        </property>
        <property name="username">
            <value>${jdbc_username}</value>
        </property>
        <property name="password">
            <value>${jdbc_password}</value>
        </property>
    </bean>

    <!-- 自动扫描了所有的XxxxMapper.xml对应的mapper接口文件,这样就不用一个一个手动配置Mpper的映射了,只要Mapper接口类和Mapper映射文件对应起来就可以了。 -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage"
            value="com.acp.dao" />
    </bean>

    <!-- 配置Mybatis的文件 ,mapperLocations配置**Mapper.xml文件位置,configLocation配置mybatis-config文件位置-->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="mapperLocations" value="classpath:mapper/*.xml"/>  
        <property name="configLocation" value="classpath:mybatis/mybatis-config.xml" />
        <!-- <property name="typeAliasesPackage" value="com.tiantian.ckeditor.model" 
            /> -->
    </bean>

    <!-- 自动扫描注解的bean -->  
    <context:component-scan base-package="com.acp.controller" >
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
    </context:component-scan>
</beans>




spring-mvc.xml

 <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.2.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">

    <mvc:resources location="/WEB-INF/js/" mapping="/js/**" />
    <mvc:resources location="/WEB-INF/css/" mapping="/css/**" />
    <mvc:resources location="/WEB-INF/images/" mapping="/images/**" />

    <!-- 扫描controller(controller层注入) -->
    <context:component-scan base-package="com.acp.controller"  use-default-filters="false">
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
    </context:component-scan>

    <!--启用 MVC注解(@Controller,@RequestMapping)实现URL映射-->
    <mvc:annotation-driven/>

    <!-- 对模型视图添加前后缀 -->
    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver"
        p:prefix="/WEB-INF/view/" p:suffix=".jsp" />

</beans>

UserController

 package com.acp.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.http.HttpEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.acp.domain.User;
import com.acp.service.UserService;

@Controller
public class UserController {

    @Resource
    private UserService userService;

    @RequestMapping("/")
    public ModelAndView getIndex() {
    ModelAndView mav = new ModelAndView("index");
    User user = userService.selectUserById(1);
    mav.addObject("user", user);
    return mav;
    }

    @RequestMapping("/qiao")
    public ModelAndView Qiao() {
    ModelAndView mav = new ModelAndView("qiao");
    User user = userService.selectUserById(2);
    mav.addObject("user", user);
    User userUpdate = new User();
    userUpdate.setUserName("SPDB");
    userUpdate.setUserPassword("8");
    userUpdate.setUserId(2);
    userService.updateUser(userUpdate);
    // userService.insertUser("胜普多邦", "10");
    // userService.deleteUser(8);

    User au = new User();
    au.setUserName("临时用户");
    au.setUserPassword("123");
    userService.addUser(au);

    Integer maxid = userService.getMaxUserId();
    User du = new User();
    du.setUserId(maxid);
    userService.deleteUser(du);
    return mav;
    }

    @RequestMapping("/userlist")
    public ModelAndView userList() {
    ModelAndView mav = new ModelAndView("userlist");
    List<User> users = userService.getAll();
    mav.addObject("users", users);
    return mav;
    }

    @RequestMapping("/detail")
    public ModelAndView userDetail(Integer userId) {
    ModelAndView mav = new ModelAndView("detail");
    User user = userService.selectUserById(userId);
    mav.addObject("user", user);
    return mav;
    }

    @RequestMapping("/adduserform")
    public ModelAndView adduserform(@ModelAttribute("user") User user) {
    userService.addUser(user);
    String message = "添加用户:" + user.getUserName() + "个人信息成功!";
    ModelAndView mav = new ModelAndView("succes");
    mav.addObject("message", message);
    return mav;
    }

    @RequestMapping("/adduserform1")
    public ModelAndView adduserform1(String userName, String userPassword) {
    User user = new User();
    user.setUserName(userName);
    user.setUserPassword(userPassword);
    userService.addUser(user);
    String message = "添加用户:" + user.getUserName() + "个人信息成功!";
    ModelAndView mav = new ModelAndView("succes");
    mav.addObject("message", message);
    return mav;
    }

    @RequestMapping("/adduserform2")
    public ModelAndView adduserform2(HttpServletRequest request) {
    User user = new User();
    user.setUserName(request.getParameter("userName"));
    user.setUserPassword(request.getParameter("userPassword"));
    userService.addUser(user);
    String message = "添加用户:" + user.getUserName() + "个人信息成功!";
    ModelAndView mav = new ModelAndView("succes");
    mav.addObject("message", message);
    return mav;
    }

    @RequestMapping("/adduser")
    public ModelAndView adduser() {
    ModelAndView mav = new ModelAndView("adduser");
    return mav;
    }

    @RequestMapping("/succes")
    public ModelAndView succesOp(String message) {
    ModelAndView mav = new ModelAndView("succes");
    mav.addObject("message", message);
    return mav;
    }

    @RequestMapping("/updateuserform")
    public ModelAndView updateuserform(@ModelAttribute("user") User user) {
    userService.updateUser(user);
    String message = "更新用户:" + user.getUserName() + "个人信息成功!";
    ModelAndView mav = new ModelAndView("succes");
    mav.addObject("message", message);
    return mav;
    }

    @RequestMapping("/updateuser")
    public ModelAndView updateuser(Integer userId) {
    User user = userService.selectUserById(userId);
    ModelAndView mav = new ModelAndView("updateuser");
    mav.addObject("user", user);
    return mav;
    }

    @RequestMapping("/deleteuser")
    public ModelAndView deleteuser(Integer userId) {
    User user = userService.selectUserById(userId);
    userService.deleteUser(user);
    String message = "删除用户:" + user.getUserName() + "个人信息成功!";
    ModelAndView mav = new ModelAndView("succes");
    mav.addObject("message", message);
    return mav;
    }

    @RequestMapping("/jquery")
    public ModelAndView jqueryIndex() {
    ModelAndView mav = new ModelAndView("jquery");
    return mav;
    }

    /**
     * 提交表单并进行运算.
     */
    @RequestMapping(value = "/addjquery", method = RequestMethod.POST)
    @ResponseBody
    public Integer addjquery(
        @RequestParam(value = "inputNumber1", required = true) Integer inputNumber1,
        @RequestParam(value = "inputNumber2", required = true) Integer inputNumber2) {
    // 实现运算
    Integer sum = inputNumber1 + inputNumber2;
    System.out.println("sum: " + sum);
    // @ResponseBody 会自动的将返回值转换成JSON格式
    // 但是你必须添加jackson的jar包!!!
    return sum;
    }

    @RequestMapping(value = "/getuserjquery/{userId}", method = RequestMethod.POST)
    public @ResponseBody User getuserjquery(
        @PathVariable("userId") String userId) {
    System.out.println("根据ID获取用户对象: " + userId);
    Map<String, User> users = new HashMap<String, User>();
    users.put("1", new User(23, "李逵", "123"));
    users.put("2", new User(24, "张三", "128"));
    users.put("3", new User(25, "李四", "125"));
    users.put("4", new User(26, "刘邦", "126"));
    users.put("5", new User(27, "王熙凤", "127"));
    return users.get(userId);
    }

    @RequestMapping(value = "/userlistjquery", method = RequestMethod.POST)
    public @ResponseBody List<User> getUsersJquery() {
    List<User> users = new ArrayList<User>();
    users.add(new User(123456, "李逵", "123"));
    users.add(new User(123457, "李四", "124"));
    users.add(new User(123458, "李三", "125"));
    users.add(new User(123459, "李五", "126"));
    return users;
    }

    @RequestMapping(value = "/usermapjquery", method = RequestMethod.POST)
    public @ResponseBody Map<String, User> getUserMapJquery() {
    Map<String, User> users = new HashMap<String, User>();
    users.put("1", new User(12345, "李逵", "123"));
    users.put("2", new User(1234, "李四", "124"));
    users.put("3", new User(123, "李三", "125"));
    users.put("4", new User(12, "李五", "126"));
    return users;
    }

}

项目结构
图片说明

http://localhost:8080/acp/
无法找到该网页

application.xml中对于controller的配置删除,然后spring-mvc.xml中启用 MVC注解放到第一句,启用注解下边配置扫描的路径。

去比较一下
http://blog.csdn.net/je_ge/article/details/53725357