HelloWorld.jsp
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<h2><s:property value="message" /></h2>
</body>
</html>HelloWorld类:
package tutorial;
import com.opensymphony.xwork2.ActionSupport;
public class HelloWorld extends ActionSupport {
public static final String MESSAGE = "Struts is up and running ...";
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;
}
}
修改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="HelloWorld" class="tutorial.HelloWorld">
<result>/HelloWorld.jsp</result>
</action>
<!-- Add your actions here -->
</package>
</struts>
分享到:
相关推荐
Struts2 Helloworld 源代码
struts2HelloWorld 简单的实用例子!
struts2 入门示例 HellWorld 工程源码。
NULL 博文链接:https://cecily.iteye.com/blog/682149
一个完整的struts2框架实现实例,需要的包、配置文件均可参考。
Struts2的入门小实例helloworld,jar包齐全,可以运行。
纠结了好久后解决掉了struts2 的helloWorld程序一系列问题,步骤以及一些错误等在我的博文里。
Struts2做的一个HelloWorld示例,使用Maven构建,导入请前先安装maven。
这个是struts2入门示例HelloWorld所需的最小必备包。
自己编写的一个helloworld. 使用struts2.0.11.2, 在eclipse3.4, tomcat5.5, jdk1.5平台上写的代码. 没有使用jarkatar提供的空白模板struts2-blank-2.0.11.2.war(发现这个模板有问题). 已集成到war文件中, 可以使用...
NULL 博文链接:https://plane.iteye.com/blog/453686
这是一个Struts2的例子,MyEclipse运行
完整项目 包 博文链接:https://huibuqule.iteye.com/blog/1882869
最基础的基于struts2框架的hello world 实现,适合小白。
学Struts2从HelloWorld示例开始
自己做的 Struts2.1.6 HelloWorld 小例子
可运行的struts2例子,eclipse工程