错误是"找不到名为' / hello / world'的bean的类[com.etc.web.controller.HelloWorldController]在ServletContext资源中定义[/WEB-INF/springMVC-servlet.xml];嵌套异常是java.lang.ClassNotFoundException:com.etc.web.controller.HelloWorldController"
" com.etc.web.controller.HelloWorldController"是我自己的项目结构。
我hava在我的springMVC-servlet.xml中写了bean,但是它没有用。
springMVC-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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean name="/hello/world" class="com.etc.web.controller.HelloWorldController"></bean>
<bean id="" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="ViewClass" value="org.springframework.web.servlet.view.JstlView"></property>
<property name="prefix" value="/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
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/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>springMVC1</display-name>
<servlet>
<servlet-name>springMVC</servlet-name>
<servlet- class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springMVC</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
答案 0 :(得分:0)
我已通过构建路径解决错误 - >配置构建路径 - &gt;源 - >源文件夹的默认输出文件夹。