Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring @ModelAttribute-绑定属性,用括号括起来,而不是用点分隔_Spring_Spring Mvc - Fatal编程技术网

Spring @ModelAttribute-绑定属性,用括号括起来,而不是用点分隔

Spring @ModelAttribute-绑定属性,用括号括起来,而不是用点分隔,spring,spring-mvc,Spring,Spring Mvc,@ModelAttribute可以将myObj.myProp绑定到以下类而不会出现问题: public class MyObj { private String myProp; // plus a default constructor and setter / getter for myProp } 但如果参数作为myObj[myProp]传递,则绑定失败。弹簧可以绑定括号中指定的属性吗 不,spring被设计为使用解释属性,因此它将作为myObj.myProp工作。我使用的U

@ModelAttribute可以将
myObj.myProp
绑定到以下类而不会出现问题:

public class MyObj {

   private String myProp;
   // plus a default constructor and setter / getter for myProp
}

但如果参数作为
myObj[myProp]
传递,则绑定失败。弹簧可以绑定括号中指定的属性吗

不,spring被设计为使用
解释属性,因此它将作为
myObj.myProp

工作。我使用的UI库使用括号表示法传递HTTP参数。不幸的是,我不能改为使用点符号。由于Spring在
org.springframework.beans.InvalidPropertyException
中出错,我必须通过
HttpServletRequest
对象获取参数。我确实发现了这一点,但不确定他们是如何让弹簧绑定与支架一起工作的。