我定义了像
这样的对象public class DrivelogBean implements Serializable{
private String backInfoIdentify;
private DriVehNum driVehNum;
public static class TotalMileageIntd implements Serializable{
private static final long serialVersionUID = -3268743972404969523L;
private String totalMileage;
private String mileageTime;
public String getTotalMileage () {
return totalMileage;
}
public void setTotalMileage (String totalMileage) {
this.totalMileage = totalMileage;
}
public String getMileageTime () {
return mileageTime;
}
public void setMileageTime (String mileageTime) {
this.mileageTime = mileageTime;
}
}
}
我的控制器就像:
@RequestMapping(value="saveDriveLog",method = RequestMethod.GET)
public @ResponseBody ResultBean saveDriveLog(DrivelogBean drivelogBean){
driveLogService.addDriveLog (drivelogBean);
ResultBean resultBean = new ResultBean();
resultBean.setRet (1);
resultBean.setDescripion (UsConstants.DRIVELOG_SAVE);
return resultBean;
}
我希望请求参数转换为drivelogBean 我的网址是这样的:
http://127.0.0.1:8080//manage/drivelog/saveDriveLog/?backInfoIdentify=2&totalMileageIntd["driverNum%22]=1&totalMileageIntd["driveCode"]=2
但页面提示
HTTP ERROR: 404 Problem accessing //manage/drivelog/saveDriveLog/error. Reason:Not Found
我更改了网址:
http://127.0.0.1:8080//manage/drivelog/saveDriveLog/?commendWord=2&totalMileageIntd.driverNum=1&totalMileageIntd.driveCode=2
但是drivelogBean参数,totalMileageIntd的属性driverNum和totalMileageIntd的属性driveCode为null。
那么如何将正确的url pass参数设置为drivelogBean?
答案 0 :(得分:1)
我不知道绑定内部静态类是否适用于春天。
您的参数必须与设定者匹配 commendWord = 2 =>你必须在类DrivelogBean上有setCommendWord totalMileageIntd.driverNum = 1 =>你必须有一个setDriverNum()和一个getTotalMileageIntd
这个类看起来应该是这样的(我跳过getter和setter来节省空间,但它们必须存在)
public class DrivelogBean implements Serializable{
private String backInfoIdentify;
private DriVehNum driVehNum;
private TotalMileageIntd totalMileageIntd ;
public static class TotalMileageIntd implements Serializable{
private static final long serialVersionUID = -3268743972404969523L;
private String totalMileage;
private String mileageTime;
}
}
在这种情况下,您可以使用的所有参数都是:
backInfoIdentify=XXX
driVehNum=XXX
totalMileageIntd.totalMileage=XXX
totalMileageIntd.mileageTime=XXX
别无其他