繁体   English   中英

如何在Struts 2中获取内容类型为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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM