1. WizardAction
package net.dev.java.teamware;
import com.opensymphony.xwork2.ActionSupport;
/**
* Created by IntelliJ IDEA.
* User: mazhao
* Date: 2008-5-5
* Time: 21:10:44
* To change this template use File | Settings | File Templates.
*/
public class WizardAction extends ActionSupport {
private String firstName;
private String lastName;
private String actionName;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getActionName() {
return actionName;
}
public void setActionName(String actionName) {
this.actionName = actionName;
}
/**
* FirstName -> LastName -> Show Name
* next submit
* FirstName <- LastName
* previous
*
* -> FirstName
* init
*
* @return
*/
public String execute() {
if ("next".equals(actionName)) {
return "next";
} else if ("previous".equals(actionName)) {
return "previous";
} else if ("submit".equals(actionName)) {
return "submit";
} else {
return "init";
}
}
}
2. struts.xml 配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="myPackage" extends="struts-default">
<action name="index" class="net.dev.java.teamware.IndexAction">
<result>/jsp/index.jsp</result>
</action>
<action name="helloWorld" class="helloWorldAction">
<result name="input">/jsp/index.jsp</result>
<result>/jsp/helloWorld.jsp</result>
</action>
<action name="wizard" class="net.dev.java.teamware.WizardAction">
<result name="init">/jsp/FirstName.jsp</result>
<result name="next">/jsp/LastName.jsp</result>
<result name="previous">/jsp/FirstName.jsp</result>
<result name="submit">/jsp/ShowName.jsp</result>
</action>
</package>
</struts>
3. JSP代码
FirstName.jsp
<%--
Created by IntelliJ IDEA.
User: mazhao
Date: 2008-5-5
Time: 21:13:59
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<html>
<head><title>Simple jsp page</title></head>
<body>
Enter your first name here!
<br/>
<s:form action="wizard" method="submit" >
<s:textfield name="firstName" label="First Name"/>
<s:submit label="Next" name="actionName" value="next"/>
</s:form>
</body>
</html>
LastName.jsp
<%--
Created by IntelliJ IDEA.
User: mazhao
Date: 2008-5-5
Time: 21:14:08
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<html>
<head><title>Simple jsp page</title></head>
<body>
Enter your last name here!
<s:form action="wizard" method="post">
<s:textfield name="firstName" label="First Name"/>
<s:textfield name="lastName" label="Last Name"/>
<s:submit label="Submit" name="actionName" value="submit"/>
<s:submit label="Previous" name="actionName" value="previous"/>
</s:form>
</body>
</html>
ShowName.jsp
<%--
Created by IntelliJ IDEA.
User: mazhao
Date: 2008-5-5
Time: 21:14:15
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<html>
<head><title>Simple jsp page</title></head>
<body>
The Name is :<br/>
<s:property value="firstName"/> <s:property value="lastName"/>
</body>
</html>
相关推荐
标题中的“axis2 webservice for myeclipse插件Axis2_Codegen_Wizard_1.2.1”是指一个专门用于MyEclipse集成开发环境的Axis2 Web服务生成向导插件,版本为1.2.1。这个插件极大地简化了在MyEclipse中创建和操作Axis2 ...
4. **JSP from ActionForm Wizard**:根据指定的 `ActionForm` 类,这个向导可以自动生成使用 Struts 标签库的 JSP 页面。 除了这些向导,JBuilder9 还能帮助开发者自动配置 `web.xml` 文件,以确保 JSP 页面能正确...
Struts Wizard是一款开源工具,专为基于Struts框架的Web应用程序设计,旨在简化向导式界面的开发。向导在Web应用中常用于引导用户通过一系列步骤完成复杂任务,如注册、设置偏好或购物过程。Struts Wizard的核心优势...
2. 在启动配置向导后,如果已有MySQL实例,可以选择“Reconfigure Instance”来重新配置。 3. 选择配置模式:“Detailed Configuration”或“Standard Configuration”,这里推荐选择“Detailed Configuration”以便...
2. **添加Struts支持**:通过MyEclipse提供的工具添加Struts框架支持,并配置Struts.xml等核心配置文件。 3. **添加Spring支持**:配置Spring的核心配置文件applicationContext.xml,并添加Bean定义等。 4. **配置...
- 使用Eclipse 4.7.3a JEE开发JEE应用时,可以通过New Project Wizard创建各种类型的JEE项目,如Web应用、EAR项目、EJB项目等。 - 内置的Tomcat、Glassfish等服务器支持,允许开发者在本地运行和测试应用,同时...
- **应用场景**: 在使用各种软件或网站服务时,通常需要先进行登录才能正常使用。 #### 25. 退出 (ログアウト | logout) - **定义**: 用户结束会话并注销账户的过程。 - **应用场景**: 为了保障信息安全,每次使用...