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; } }
时间: 2024-10-08 10:21:33