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="jason" namespace="/test" extends="struts-default">
<action name="hello" class="action.HelloWordAction" method="execute">
<result name="success">/page/hello.jsp</result>
</action>
</package>
</struts>web.xml配置<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<welcome-file-list>
<welcome-file>index.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>HelloWordActionpackage action;public class HelloWordAction
{
public String message; public String getMessage()
{
return message;
} public String execute()
{
message = "Hello Word!";
return "success";
}
}运行信息:
2012-10-21 21:15:02 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\Program Files\MyEclipse 6.5\bin;D:\Program Files\Tomcat 6.0\bin
2012-10-21 21:15:02 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2012-10-21 21:15:02 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 871 ms
2012-10-21 21:15:02 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2012-10-21 21:15:02 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.18
2012-10-21 21:15:04 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts-default.xml]
2012-10-21 21:15:04 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Unable to locate configuration files of the name struts-plugin.xml, skipping
2012-10-21 21:15:04 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts-plugin.xml]
2012-10-21 21:15:05 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts.xml]
2012-10-21 21:15:07 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts-default.xml]
2012-10-21 21:15:07 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Unable to locate configuration files of the name struts-plugin.xml, skipping
2012-10-21 21:15:07 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts-plugin.xml]
2012-10-21 21:15:07 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts.xml]
2012-10-21 21:15:08 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2012-10-21 21:15:08 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2012-10-21 21:15:08 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/31 config=null
2012-10-21 21:15:08 org.apache.catalina.startup.Catalina start
信息: Server startup in 6065 ms初学struts,我的访问路径是:http://localhost:8080/Struts2_HelloWord/test/hello,但是hello不起来,相应的包都导入进来了,包名。类名都配置了
<!DOCTYPE struts PUBLIC "//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="jason" namespace="/test" extends="struts-default">
<action name="hello" class="action.HelloWordAction" method="execute">
<result name="success">/page/hello.jsp</result>
</action>
</package>
</struts>web.xml配置<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<welcome-file-list>
<welcome-file>index.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>HelloWordActionpackage action;public class HelloWordAction
{
public String message; public String getMessage()
{
return message;
} public String execute()
{
message = "Hello Word!";
return "success";
}
}运行信息:
2012-10-21 21:15:02 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\Program Files\MyEclipse 6.5\bin;D:\Program Files\Tomcat 6.0\bin
2012-10-21 21:15:02 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2012-10-21 21:15:02 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 871 ms
2012-10-21 21:15:02 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2012-10-21 21:15:02 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.18
2012-10-21 21:15:04 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts-default.xml]
2012-10-21 21:15:04 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Unable to locate configuration files of the name struts-plugin.xml, skipping
2012-10-21 21:15:04 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts-plugin.xml]
2012-10-21 21:15:05 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts.xml]
2012-10-21 21:15:07 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts-default.xml]
2012-10-21 21:15:07 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Unable to locate configuration files of the name struts-plugin.xml, skipping
2012-10-21 21:15:07 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts-plugin.xml]
2012-10-21 21:15:07 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts.xml]
2012-10-21 21:15:08 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2012-10-21 21:15:08 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2012-10-21 21:15:08 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/31 config=null
2012-10-21 21:15:08 org.apache.catalina.startup.Catalina start
信息: Server startup in 6065 ms初学struts,我的访问路径是:http://localhost:8080/Struts2_HelloWord/test/hello,但是hello不起来,相应的包都导入进来了,包名。类名都配置了
解决方案 »
- 调用 支付接口 需要注意的事项
- linux自带的sendmail向hotmail或者sina发邮件时对方收不到
- Java 去掉软回车标记
- 有什么经验教训?
- 高手请进:请问如何用java实现动态webservice客户端
- 求救:TOMCAT session问题
- 求医院排队系统的一切资料!
- JBoss,EJB-QL的疑问。
- 关于Exception问题
- jb7+WL开发ejb时,一个finder方法的问题,编译出错
- 用Jsp做个网站,其中有一项需要向数据库中插入日期时间(时间格式形如2012-04-30),在数据库中该字段数据类型为datetime,现如今用户提交表单老是错
- java web显示硬盘上的pdf的问题
HTTP Status 404 - /Struts2_HelloWord/test/hello.action
HTTP Status 404 - /Struts2_HelloWord/test/hello.action
你先试试能不能进tomcat 然后再进自己的项目里。
两者矛盾。
这个page/hello.jsp 我是放在WEB-INF中的,忘了把WEB-INF写上了
如果成功 返回success,跳转到hello.jsp页面
你是指HellloWordAction 这个类要继承ActionSupport?
<action name="hello" class="action.HelloWordAction" method="execute">
<result name="success">/page/hello.jsp</result>
</action>
</package>改成这个就行了<result name="success">/WEB-INF/page/hello.jsp</result>
把这个改成相应的试一试。
如果你解决了 请告诉我方法 小弟初学者 请多指教
我的目录就是这样写的忘了加上去
<result name="success">/WEB-INF/page/hello.jsp</result>