码迷,mamicode.com
首页 > 其他好文 > 详细

Struts2-在action中获取表单提交的参数

时间:2015-07-17 13:54:28      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:

1、表单

    <form action="<%=path %>/FirstAction" method="post">
        <input type="text" name="username">
        <input type="submit" name="提交">
    </form>

2、action代码

package com.action;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

public class FirstAction {
    private String username;
    
    public String execute(){
        HttpServletRequest request = ServletActionContext.getRequest();
        username = request.getParameter("username");        
        System.out.println(username);
        return null;        
    }
}

 

Struts2-在action中获取表单提交的参数

标签:

原文地址:http://www.cnblogs.com/Arvin-9/p/4653890.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!