大家好,俺刚开始学SSH,
一个简单的Helloworld.jsp例子 如下<%@ page contentType=" text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<title>Hello World!</title>
</head>
<body>
信息
<h1><s:property value="message" /></h1>
</body>
</html>配置完毕启动tomcat后,访问Helloworld.jsp,网页上看不到s:property标签的message信息。但是访问Helloworld.action是正常的。请问是为什么?谢谢。struts.xml: <package name="hello" extends="struts-default">
<action name="HelloWorld" class="hello.HelloWorld">
<result>/HelloWorld.jsp</result>
</action>
<!-- Add your actions here -->
</package>
一个简单的Helloworld.jsp例子 如下<%@ page contentType=" text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<title>Hello World!</title>
</head>
<body>
信息
<h1><s:property value="message" /></h1>
</body>
</html>配置完毕启动tomcat后,访问Helloworld.jsp,网页上看不到s:property标签的message信息。但是访问Helloworld.action是正常的。请问是为什么?谢谢。struts.xml: <package name="hello" extends="struts-default">
<action name="HelloWorld" class="hello.HelloWorld">
<result>/HelloWorld.jsp</result>
</action>
<!-- Add your actions here -->
</package>
package hello;
import java.util.Date;
import java.text.DateFormat;
import com.opensymphony.xwork2.ActionSupport;
public class HelloWorld extends ActionSupport {
/**
*
*/
private static final long serialVersionUID = 1L;
private String message;
public String getMessage() {
//System.out.println(message);
return message;
}
public String execute() {
message = "Hello World, Now is "
+ DateFormat.getInstance().format(new Date());
return SUCCESS;
}
}
楼主debug 看看
<action name="HelloWorld" class="hello.HelloWorld">
<result>/HelloWorld.jsp</result>
</action>
<!-- Add your actions here -->
</package><result name="success">/HelloWorld.jsp</result>
网页上查看源代码是有h1的标签的。但是无内容显示
<html>
<head>
<title>Hello World!</title>
</head>
<body>
信息
<h1></h1></body>
</html>
但是访问action就没问题
this.message = message;
}