spring mvc @ModelAttribute @RequestParam

本文探讨了Spring MVC框架中如何使用@RequestParam和@ModelAttribute进行参数绑定,包括URL参数、Form表单数据的处理方式及注意事项。同时介绍了@ModelAttribute预处理方法的应用场景。

从Form表单或URL参数中获取(实际上,不做此注释也能拿到对象) 注意这时候这个User类一定要有没有参数的构造函数。

@RequestMapping("updateAnesthesiainfoNon.action")
public ModelAndView updateAnesthesiainfoNon(HttpServletRequest request,HttpServletResponse response,@ModelAttribute AnesthesiainfoNon infoNon){

}

 

$.ajax({
        url: $("#basepath").val()+"/updateAnesthesiainfoNon.action?anInfoId="+$("#anInfoId").val(),
        data:$('#addform').serialize(),// 你的formid???

});

anInfoId会装载在infoNon对象上吗???好像是绑定不上???

----------------------------------------------------------------------------------------------------------

@ModelAttribute
public void preRun() {
    System.out.println("Test Pre-Run");
}

在调用所有方法之前,都会先执行preRun()方法。

原文链接    http://www.cnblogs.com/HD/p/4127915.html

原文链接    http://www.bubuko.com/infodetail-649956.html

----------------------------------------------------------------------------------------------------------

 

 

@RequestMapping("toIcutreatmentDataTabPage.action")
public String toRegistrationDataTabPage(@RequestParam("icutreatmenttype") String icutreatmenttype,@RequestParam("p_pk") String p_pk , ModelMap modelMap,
            HttpServletRequest request ){   

 

document.getElementById("optype1_frame").src=

$("#basepath").val()+'/toIcutreatmentDataTabPage.action?icutreatmenttype=fluidTherapy&p_pk=0';

----------------------------------------------------------------------------------------------------------

@RequestParam("fid") String fid                         必须存在,不存在报错
@RequestParam(value="fid", required = false) String fid   不存在返回null

原文链接   http://825635381.iteye.com/blog/2196911

----------------------------------------------------------------------------------------------------------

 

转载于:https://www.cnblogs.com/xmyclass/articles/4689379.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值