首页>代码>struts2的简单demo实例源代码下载>/struts/src/example/HelloWorld.java
package example;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

/**
 * <code>Set welcome message.</code>
 */
public class HelloWorld extends ActionSupport {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -28426643809171267L;
	private String mes;
	private String abc;

	
	public String getMes() {
		return mes;
	}

	public void setMes(String mes) {
		this.mes = mes;
	}

	public String getAbc() {
		return abc;
	}

	public void setAbc(String abc) {
		this.abc = abc;
	}

	public String execute() throws Exception {
    	//���request�ķ���
    	//Map<?,?> request = (Map<?,?>)ActionContext.getContext().get("request");
		ActionContext context=ActionContext.getContext();
        Map<String,Object> parameterMap = (Map<String,Object>)context.getParameters();
        System.out.println( parameterMap.get("mes") );
    	HttpServletRequest request = ServletActionContext.getRequest();
    	System.out.println( request.getParameter("mes"));
    	System.out.println( request.getParameter("abc"));
    	System.out.println(mes);
    	System.out.println( abc );
        setMessage(getText(MESSAGE));
        return SUCCESS;
    }

    /**
     * Provide default valuie for Message property.
     */
    public static final String MESSAGE = "HelloWorld.message";

    /**
     * Field for Message property.
     */
    private String message;

    /**
     * Return Message property.
     *
     * @return Message property
     */
    public String getMessage() {
        return message;
    }

    /**
     * Set Message property.
     *
     * @param message Text to display on HelloWorld page.
     */
    public void setMessage(String message) {
        this.message = message;
    }
}

最近下载更多
Qolmen  LV12 2024年1月9日
1306878374  LV13 2022年4月11日
阳夏居士  LV1 2021年5月10日
AlanYang  LV5 2021年1月20日
a294056932  LV1 2020年10月24日
yang2001  LV5 2020年9月16日
zms525853  LV1 2020年7月9日
y6622576  LV9 2020年6月7日
cz206616  LV10 2020年5月29日
tttttt1  LV2 2020年4月15日
最近浏览更多
Qolmen  LV12 2024年1月9日
yiming223 2022年12月2日
暂无贡献等级
1938953205  LV1 2022年5月18日
1306878374  LV13 2022年4月11日
王勇是你爹爹  LV1 2021年11月5日
飞翔的面包片  LV13 2021年7月3日
好的好的  LV8 2021年6月22日
北冥有猫  LV2 2021年6月14日
chengyan1984  LV2 2021年5月31日
阳夏居士  LV1 2021年5月10日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友