SSH 初学之 HelloWorld
steli 2012-11-29 12:41:18 【问题】
如何不点击提交按钮,就能显示Server端的信息?
【环境】
eclipse7.5 JRE7 J2EE1.4 tomcat7
【struts.xml】
<action name="HelloWorld2" class="helloWorld.HelloWorld2">
<result name="SUCCESS">/HelloWorld2.jsp</result>
</action>
【action】
public class HelloWorld2{
private String message;
public String getMessage() {
return message;
}
public String execute() throws Exception{
message = "HelloWorld2 from server";
return "SUCCESS";
}
}
【jsp】
<%@ page contentType="text/html;charset=GBK" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="/struts-tags" prefix="s" %>
<html>
<head>
<title>Hello World2</title>
</head>
<body>
<s:form action="HelloWorld2" >
<h1><s:property value="message"/></h1>
<!-- <s:submit/>
--> </s:form>
</body>
</html>