1.通常情况下都是访问路径拼写错误问题
2.考虑是否与请求方式有关系(post,get)
3.考虑spring没有装载你写的controller类
比如ApplicationContext-mvc.xml里面,当测试的controller类并没有放在指定的包路径下面,spring是不会它的,所以就访问不到了。
<?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:p="http://www.springframework.org/schema/p" xmlns:mvc="http://www.springframework.org/schema/mvc" 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.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <mvc:annotation-driven/> <mvc:default-servlet-handler/> <context:component-scan base-package="com.ojbk.controller"/>