我使用struts2完成了一个项目。现在我正在尝试将瓷砖合并到我的项目中,所以我开始学习瓷砖。我在构建我的第一个示例页面时在控制台中出现以下错误。
SEVERE: Exception starting filter struts2
java.lang.NoClassDefFoundError: com/opensymphony/xwork2/config/FileManagerProvider
at org.apache.struts2.dispatcher.Dispatcher.init_FileManager(Dispatcher.java:352)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:481)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4809)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5485)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:672)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1862)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.opensymphony.xwork2.config.FileManagerProvider
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
... 20 more
通过互联网我认为错误可能是因为我正在使用的罐子...所以我也在发布我的罐子。
我的struts.xml文件是
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="default" extends="struts-default">
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/>
</result-types>
<action name="*Link" method="{1}" class="com.classes.JustJsps">
<result name="welcome" type="tiles">welcome</result>
<result name="login" type="tiles">login </result>
</action>
</package>
</struts>
我的tiles.xml文件是
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
<tiles-definitions>
<definition name="welcome" template="/baseLayout.jsp">
<put-attribute name="title" value="DReST" type="string" />
<put-attribute name="myHeader" value="/head.jsp"/>
<put-attribute name="myMenu" value="/menu.jsp"/>
<put-attribute name="myBody" value="/home.jsp"/>
<put-attribute name="myFooter" value="/footer.jsp"/>
</definition>
<definition name="login" extends="welcome">
<put-attribute name="myBody" value="/login.jsp"/>
</definition>
</tiles-definitions>
我的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"
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>Tiles</display-name>
<context-param>
<param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
<param-value>/WEB-INF/tiles.xml</param-value>
</context-param>
<listener>
<listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
<filter>
<filter-name>struts2</filter-name>
<filter- class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
的index.jsp
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=welcomeLink.action">
welcomeLink.action
返回&#39; welcome&#39;。我在做什么错误?
答案 0 :(得分:0)
还要注意使用正确的配置(听众,结果等):阅读this topic了解更多详情。