HelloReader.jsp的代码:
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>TEST</title>
</head>
<body>
<h2><s:property value="message" /></h2>
</body>
</html>
web.xml的代码:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" 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">
<display-name>Struts Blank</display-name>
<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>
</web-app>struts.xml的代码:
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="tutorial" extends="struts-default">
<action name="HelloReader" class="tutorial.HelloReader">
<result>/HelloReader.jsp</result>
</action>
</package>
</struts>
HelloReader.java的代码:
package tutorial;
import com.opensymphony.xwork2.ActionSupport;
public class HelloReader extends ActionSupport { public static final String MESSAGE = "Hello Reader ! I'm from Struts 2"; public String execute() throws Exception {
setMessage(MESSAGE);
return SUCCESS;
}
private String message;
public void setMessage(String message){
this.message = message;
} public String getMessage() {
return message;
}
}
没有用到其他文件了,在IE中输入http://localhost:8081/Struts2/HelloReader.action时显示内容如下:HTTP Status 404 - --------------------------------------------------------------------------------type Status reportmessage description The requested resource () is not available.
--------------------------------------------------------------------------------Apache Tomcat/6.0.20
这是怎么回事啊,我都调了3个小时了,请大家赐教。
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>TEST</title>
</head>
<body>
<h2><s:property value="message" /></h2>
</body>
</html>
web.xml的代码:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" 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">
<display-name>Struts Blank</display-name>
<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>
</web-app>struts.xml的代码:
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="tutorial" extends="struts-default">
<action name="HelloReader" class="tutorial.HelloReader">
<result>/HelloReader.jsp</result>
</action>
</package>
</struts>
HelloReader.java的代码:
package tutorial;
import com.opensymphony.xwork2.ActionSupport;
public class HelloReader extends ActionSupport { public static final String MESSAGE = "Hello Reader ! I'm from Struts 2"; public String execute() throws Exception {
setMessage(MESSAGE);
return SUCCESS;
}
private String message;
public void setMessage(String message){
this.message = message;
} public String getMessage() {
return message;
}
}
没有用到其他文件了,在IE中输入http://localhost:8081/Struts2/HelloReader.action时显示内容如下:HTTP Status 404 - --------------------------------------------------------------------------------type Status reportmessage description The requested resource () is not available.
--------------------------------------------------------------------------------Apache Tomcat/6.0.20
这是怎么回事啊,我都调了3个小时了,请大家赐教。
Tomcat 6.0\webapps\Struts2\WEB-INF下有文件web.xml
Tomcat 6.0\webapps\Struts2\WEB-INF\classes下有文件struts.xml
D:\Tomcat 6.0\webapps\Struts2\WEB-INF\classes\tutorial有文件HelloReader.class不知道还需要不需要其它的配置文件,望赐教。
是不是web.xml中的org.apache.struts2.dispatcher.FilterDispatcher 的问题,
难道不需要其它的配置文件了吗?
<%@ taglib prefix="s" uri="/struts-tags" %> 这一句中的URI引用的好像也不对吧
在web.xml文件中你好像也没有配置Struts所需要的xml文件默认的是struts-config.xml
建议你去看一下Struts中给你带的那个空项目,里面所有基本的配置。