为了避免错误,我从struts官网上下了一个例子,跑起来也没有问题,在这个基础上我添加自己的action还有jsp 这个是我添加action后的struts.xml
- HTML code
<!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"> <action name="HelloWorld" class="vaannila.HelloWorld"> <result name="SUCCESS">/success.jsp</result> </action> <action name="submit" class="action.LoginAcion" method="submit"> <result name="success">/submit.jsp</result> </action> <action name="toSubmit" class="action.LoginAction" method="toSubmit" > <result name="success" type="redirectAction"> <param name="actionName">submit</param> </result> </action> </package></struts>
web.xml如下,我没有改过
- HTML code
<?xml version="1.0" encoding="UTF-8"?><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.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
文件目录结构如下
但是却出现 type Status report message description The requested resource () is not available.
请问是怎么回事啊?
------解决方案--------------------
应该是web应用部署没有成功,启动tomcat的时候看下报错没
------解决方案--------------------
<action name="submit" class="action.LoginAcion" method="submit">
<result name="success">/submit.jsp</result>
</action>
名称写错了
<action name="submit" class="action.LoginAction" method="submit">
你少写了个t
认真点啊