web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" metadata-complete="true" version="3.1">
<filter>
<filter-name>struts</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts</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="hello" extends = "struts-default">
<action name="hello" class="Action.HelloAction">
<result name = "success">/index.jsp</result>
</action>
</package>
</struts>
action类
**package action;
public class HelloAction {
public String execute(){
System.out.println("hello struts2");
return "success";
}
}
错误提示:
ERROR org.apache.struts2.dispatcher.Dispatcher - Dispatcher initialization failed
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
后面还有一些列错误,包括 无法初始化filter什么的一系列,问题描述看起来特别像jar包没有正确导入,但是我从官网上下的,原封不动的导入进入lib,为了怕官方jar包错误,我还特意把空项目war解压下来在lib中找到ar包导入,可是还是出问题,用的服务器是tomcat,特来求解
头都大了,查了好多资料,都不是我遇到的情况,求大大们看一下,才开始学习struts不久,用的myeclipse blue edition,头疼。。。