ClassNotFoundException和导入问题使用jsp:include with Spring MVC
我制作了一个简单的JSP应用程序原型。所有页面都可以正常工作,没有任何问题。现在,我添加了SpringMVC来开始实现动态行为。仅添加DispatcherServlet并使用此配置:ClassNotFoundException和导入问题使用jsp:include with Spring MVC,spring,jsp,spring-mvc,model-view-controller,include,Spring,Jsp,Spring Mvc,Model View Controller,Include,我制作了一个简单的JSP应用程序原型。所有页面都可以正常工作,没有任何问题。现在,我添加了SpringMVC来开始实现动态行为。仅添加DispatcherServlet并使用此配置: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schem
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
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-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="my.controllers" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/views/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
我的包结构是:
my.components
Button
Label
Textbox
etc...
my.model
my.data
...
其次,在没有导入的页面中,当我使用jsp:include(必须使用它,因为jsp片段使用参数)时,会出现以下错误:
Only a type can be imported. my.components.Label resolves to a package
org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.WEB_002dINF.views.fragments.header_jsp
这似乎很奇怪,因为没有使用SpringMVC,所有的程序都能完美运行。有什么想法吗?它没有解析,或者找不到my.components.Button。你能发布你的包结构吗?我认为包结构是正确的,因为我在Eclipse中使用Ctrl+Space添加了导入,当我按下Ctrl+左键单击时,它可以导航到类。另外,我删除了类导入,通过自动完成添加,结果是一样的。我已经复制了包声明和类名并粘贴到import子句中,但仍然失败。这很奇怪。
org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.WEB_002dINF.views.fragments.header_jsp