Struts2用action类从jsp中获取select中option的value值

2024-11-24 05:20:11
推荐回答(3个)
回答1:

jsp页面部分代码:



action类:
public class GlydengluAction extends ActionSupport {
private String role;

@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
return super.execute();
}

public String denglu(){
HttpServletRequest request = ServletActionContext.getRequest();
String roles = request.getParameter("role");

if(rand_input.equals(rand)){
System.out.println(roles);
return SUCCESS;
}else{
return INPUT;
}
}
}

System.out.println(roles);打印出来的就是option的value值。

回答2:

就和普通参数一样获取哇,你就当是Input一样取就行了

回答3:

request.getParameter(" ");