如图所示,这个异常网上很多答案说是jdk版本过高,但是不能解决问题,我的jsk15都没有问题;由此可见,不是jdk版本的问题
jdk都是向下兼容的,不存在版本过高问题
以下是我的解决访问:
问题:DispatcherServlet-servlet.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:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-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/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
<!--1.配置一个url处理映射
url的配置方式有三种: [通过访问的路径找到对应的控制器]
2.BeanNameUrlHandlerMapping:找一个请求一个控制器处理 通过url的名字找到对应bean的name
SimpleControllerHandlerAdapter:简单那的url处理映射 通过key找到bean的id控制器
3.ControllerClassNameHandelMapper:[控制器的类名处理映射] 不用配置访问路径
默认的访问路径就是类名 大写首字母变小写 加.do的后缀 userController.do
-->
<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"></bean>
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/user1.do">userController</prop>
<prop key="/http.do">http</prop>
<prop key="/user3.do">userController</prop>
</props>
</property>
</bean>
<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"></bean>
<!--2.配置一个适配器处理适配器 :相当于配置了一个访问路径: 配置如何调用控制器的方法
两种方式:SimpleControllerHandlerAdapter 动能:执行controller,调用controller里面的handleRequest方法
返回mdeAndView
第二种:httpRequstHandlerAdapter 负责调用httpRequestHandler
-->
<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"></bean>
<bean class="org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter"></bean>
<!--3.配置控制器-->
<!-- <bean name="/user.do" class="com.cwl.backoffice.web.controller.UserController"></bean>-->
<!--3.相当于 name = /user.do
id="userController"
-->
<bean id="userController" class="com.cwl.backoffice.web.controller.UserController"></bean>
<bean name="/http.do" id="http" class="com.cwl.backoffice.web.controller.HttpController"></bean>
<bean name="/useradd.do" class="com.cwl.backoffice.web.controller.UserAddController"></bean>
<!--4.配置资源解析器-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!--前缀-->
<property name="prefix" value="/WEB-INF/views"></property>
<!--后缀-->
<property name="suffix" value=".jsp"></property>
</bean>
</beans>
没有配置id 或者是吧class写成了name,改过来就可以了;
<bean name="/http.do" id="http" class="com.cwl.backoffice.web.controller.HttpController"></bean
一定要搞清楚id name class的作用
id: 标识
name: 访问路径
class:资源路径