日期:2014-05-17 浏览次数:20759 次
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.locale" value="zh_CN" />
<constant name="struts.il8n.encoding" value="UTF-8" />
<package name="helloworld" extends="struts-default">
<action name="helloworldAction" class="com.java.helloworld.struts2impl.action.HelloWorldAction">
<result name="toWelcome" >/s2impl/welcome.jsp</result>
<result name="input" >/s2impl/login.jsp</result>
</action>
</package>
</struts>
package com.java.helloworld.struts2impl.module;
public class HelloWorldModule {
private String account;
private String password;
private String submitFlag;
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getSubmitFlag() {
return submitFlag;
}
public void setSubmitFlag(String submitFlag) {
this.submitFlag = submitFlag;
}
}
package com.java.helloworld.struts2impl.action;
import com.opensymphony.xwork2.ActionSupport;
import com.java.helloworld.struts2impl.module.*;
public class HelloWorldAction extends ActionSupport {
//使用属性模型(直接使用域对象)
private HelloWorldModule hwm = new HelloWorldModule();
public HelloWorldModule getHwm(){
return hwm;
}
public void setHwm(HelloWorldModule hwm){
this.hwm = hwm;
}
@Override
public String execute() throws Exception {
System.out.println("属性驱动(使用域对象输入参数) :account=" + hwm.getAccount() + " password= "
+ hwm.getPassword() + " submitFlag=" + hwm.getSubmitFlag());
return "toWelcome";
}
}
<%@ page language="j