[英]How to write controller class to allow content-type: application/json and application/x-www-form-urlencoded
[英]How to get the param which content-type is x-www-form-urlencoded in Struts 2
在服务器中,我有一个像这样的bean:
@Data
public class TechInfo {
private int shopID;
private String name;
private int experience;
TechnicianTitleInfo technicianTitleInfo;
private String skill;
}
如何在Struts2中获取请求参数?
我在我的操作中声明了一个TechInfo,但是在Struts2解析它之后它的值为null。
行动是这样的:
public class AjaxAction{
@Getter @Setter private TechInfo techInfo;
protected void jsonExecute() throws Exception {
//need the techInfo
}
}
正确的参数格式是使用Dot Notation的格式:
techInfo.picID
techInfo.name
techInfo.technicianTitleInfo.titleId
等等。
如何获取内容类型为x-www-form-urlencoded的参数
Struts2正在使用request.getParameterMap()
。
我在我的操作中声明了一个TechInfo,但是在Struts2解析它之后它的值为null。
该值为null
因为TechInfo
未绑定到操作类变量。 请求参数名称应与变量名称techInfo
相同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.