java - 如何在Struts 2中获取内容类型为x-www-form-urlencoded的参数

标签 java struts2 parameter-passing httprequest getter-setter

请求是这样的: enter image description here

在服务器中,我有一个像这样的bean:

@Data
public class TechInfo {
    private int shopID;    
    private String name;   
    private int experience;   
    TechnicianTitleInfo technicianTitleInfo;  
    private String skill;
}

如何获取Struts2中的请求参数?

我在我的操作中声明了一个 TechInfo,但在 Struts2 解析它之后它的值为 null。

Action 是这样的:

public class AjaxAction{

    @Getter @Setter private TechInfo techInfo;

    protected void jsonExecute() throws Exception {
      //need the techInfo
    }
}

最佳答案

正确的参数格式是使用点表示法的格式:

techInfo.picID
techInfo.name
techInfo.technicianTitleInfo.titleId

等等。

关于java - 如何在Struts 2中获取内容类型为x-www-form-urlencoded的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41389854/

相关文章:

javascript - this.form 没有在 JavaScript 函数中传递表单

python - Python 中默认参数的范围

java - 使用java检查十进制数顺序的逻辑

Java线程疑惑

struts2 - 如何用struts2创建动态图像?

tomcat - 通过 tomacat8 和 Struts2 的 SSL

c++ - 修改函数内的指针(将另一个指针作为参数传递)

java - 无法为第二种情况映射 OneToMany 和 ManyToOne?

java - 为 SimpleEntry 添加 Comparable 接口(interface)

java - 在哪里把 log4j.xml 放在 tomcat 7 上?