SSH 初学之 HelloWorld

steli steli 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
【问题】
如何不点击提交按钮,就能显示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>
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
steli
Java EE 67,535 成员 225,843 内容