【发布时间】:2013-11-30 21:53:46
【问题描述】:
我正在编写 JavaBrains 教程,完成课程后,Tomcat 说:
SEVERE: Exception starting filter struts2
还有:
Caused by: Unable to load configuration. - action - file:/Users/jasonrodriguez/Java/apache-tomcat-7.0.47/wtpwebapps/TutorialFinder/WEB-INF/classes/struts.xml:8:83
Caused by: Action class [org.koushik.javabrains.action.TutorialAction] not found - action - file:/Users/jasonrodriguez/Java/apache-tomcat-7.0.47/wtpwebapps/TutorialFinder/WEB-INF/classes/struts.xml:8:83
我回去检查,我的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>TutorialFinder</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<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>
</web-app>
我的struts.xml 有命名空间、动作名称和类属性:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="default" namespace="/tutorials" extends="struts-default">
<action name="getTutorial" class="org.koushik.javabrains.action.TutorialAction">
<result name="success">/success.jsp</result>
<result name="failure">/error.jsp</result>
</action>
</package>
</struts>
我的库构建路径是正确的,但是当我运行 Tomcat 时,它告诉我资源不可用,由于我是新手,我不知道如何解决它,因为我的项目中没有红色 x 标记.我想也许某处有一个不合适的文件,但它看起来很直接:
也许一双新鲜的眼睛可以捕捉到我错过的东西。昨天我在本教程中遇到了类似的问题,解决方案是在我的操作标记中提供类路径中存在的类引用。但是,据我所知,该标签已经看起来正确。我的目标是让我创建并执行的业务服务。
【问题讨论】:
标签: java eclipse tomcat configuration struts2