我的网站目录结构 是自己建立的,目录结构如下:
struts_web
|_WEB_INF
| |_lib
| |_Beans
| |_web.xml
| |_classes
| |_struts.xml
| |_Action class文件
|____网站和java文件
(1)我安装的是struts2.2.3
(2)lib目录下有如下jar文件:
struts2-core-2.2.3.jar
xwork-core-2.2.3.jar
ongl-3.0.1.jar
jvassist-3.11.0.GA.jar
freeer-2.3.16.jar
commons-logging-1.1.1.jar
commons-logging-api-1.1.1.jar
commons-io-2.0.1.jar
commons-fileuload-1.2.2.jar
commons-lang-2.5.jar
(3)web.xml内容:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class> <!—2.2.1版本以前不是上述类名-->
</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>
(4)struts.xml内容
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration
2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="basicstruts2" extends="struts-default">
<action name="first">
<result>/index.jsp</result>
</action>
<action name="getsum" class="action.Sum"> <!--action为包名-->
<result name="positive">/positive.jsp</result>
<result name="negative">/negative.jsp</result>
</action>
</package>
</struts>
(5)tomcat虚拟目录设置绝对没问题!
我每次运行的时候出现Http 404错误这是怎么回事?网上说缺jar文件,我需要的jar文件都拷贝过去了!
struts_web
|_WEB_INF
| |_lib
| |_Beans
| |_web.xml
| |_classes
| |_struts.xml
| |_Action class文件
|____网站和java文件
(1)我安装的是struts2.2.3
(2)lib目录下有如下jar文件:
struts2-core-2.2.3.jar
xwork-core-2.2.3.jar
ongl-3.0.1.jar
jvassist-3.11.0.GA.jar
freeer-2.3.16.jar
commons-logging-1.1.1.jar
commons-logging-api-1.1.1.jar
commons-io-2.0.1.jar
commons-fileuload-1.2.2.jar
commons-lang-2.5.jar
(3)web.xml内容:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class> <!—2.2.1版本以前不是上述类名-->
</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>
(4)struts.xml内容
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration
2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="basicstruts2" extends="struts-default">
<action name="first">
<result>/index.jsp</result>
</action>
<action name="getsum" class="action.Sum"> <!--action为包名-->
<result name="positive">/positive.jsp</result>
<result name="negative">/negative.jsp</result>
</action>
</package>
</struts>
(5)tomcat虚拟目录设置绝对没问题!
我每次运行的时候出现Http 404错误这是怎么回事?网上说缺jar文件,我需要的jar文件都拷贝过去了!
struts_web
|_WEB_INF
| |_lib
| |_Beans
| |_web.xml
| |_classes
| |_struts.xml
| |_Action class文件
|____网站和java文件