我在 Struts 2 中使用
ModelDriven
,这样我的模型对象内部就有另一个具有属性的对象。我正在进行 AJAX 调用,并希望我的模型对象由 User
填充。
JSP:
<s:select list="#session.circleIdNameMap"
headerKey="-1" headerValue="Select Circle"
name="id.circleId" id="selectCircleDropDown"
onchange="findTspNameIdMap(this.value)">
</s:select>
JS:
$.ajax({
type: 'POST',
url: '/gma/findTspNameIdMap.action',
data:
{
id.circleId: circleId,
minNumberOc: $("[name='minNumberOc']").val(),
minDurationOc: $("[name='minDurationOc']").val(),
},
但是,在 firebug 中我收到错误
SyntaxError: missing : after property id
id.circleId: circleId,
但其他直接属性如
minNumberOc
工作正常,但不是id.anything
。我正在发布我的模型对象和 Action 类。
GmaThreshold参数:
public class GmaThresholdParameter implements Serializable {
private static final long serialVersionUID = 1L;
@EmbeddedId
private GmaThresholdParameterPK id;
//getter/setters of id
GmaThresholdParameterPK:
public class GmaThresholdParameterPK implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name="CIRCLE_ID")
private int circleId;
@Column(name="TSP_ID")
private int tspId;
private String flag;
//getter/setters
动作类:
public class ConfigureTspThresholdAction extends ActionSupport implements SessionAware, ModelDriven<GmaThresholdParameter>{
private Map<String,String> circleIdNameMap;
// MODEL object
GmaThresholdParameter gmaThresholdParameters = new GmaThresholdParameter();
.....
...
public GmaThresholdParameter getGmaThresholdParameters() {
return gmaThresholdParameters;
}
public void setGmaThresholdParameters(
GmaThresholdParameter gmaThresholdParameters) {
this.gmaThresholdParameters = gmaThresholdParameters;
}
@Override
public GmaThresholdParameter getModel() {
return gmaThresholdParameters;
}
如何设置
id
对应的属性?为什么 Firebug 会报错?
为什么Firebug会报错?
因为下面的语句后面有一个逗号
minDurationOc: $("[name='minDurationOc']").val(),