`
y806839048
  • 浏览: 1119869 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

关于参数传递接受@RequestBody 写的位置不同决定返回list还是单个实体

 
阅读更多
//关于参数传递接受,有些参数不是required,可以不传进来,
//写在外面的时候里面的只能是单个实体
@RequestMapping(value = "/savemobile")
@RequestBody
    public int saveMobile(@RequestBody List<User> user ,@RequestParam(value = "yzm", required = false) String yzm) {
@RequestMapping(value = "/savemobile")//这中不可以
    public int saveMobile(@RequestBody List<User> user ,@RequestParam(value = "yzm", required = false) String yzm) {
@RequestMapping(value = "/savemobile")//这种可以
@RequestBody
    public int saveMobile(@RequestBody List<User> user ) {//这种可以
@RequestMapping(value = "/savemobile")
    @ResponseBody//这种可以
    public String saveMobile(@RequestParam(value = "yzm", required = false) String yzm , User user ) {

   @ResponseBody//写在外面的时候里面的只能是单个实体
    public PageInfo<Role> queryPageSupplier(HttpSession session,
    @RequestParam(value = "pageNo", required = false) int pageNo,
                                            @RequestParam(value = "pageSize", required = false) int pageSize,
                                            Role role)




    @RequestMapping(value = "/savemobile")
    @ResponseBody
    public String saveMobile(@RequestParam(value = "yzm", required = false) String yzm , User user ) {
$.ajax({

            type: "post",
            url: "<%=webPath%>/system/users/savemobile.do",
            data: ndata,
            dataType: "json",/////////////////////////////    contentType:"application/json",不用list之后这句去了【】是复杂格式标志
            success: function (data) {
                if (data = 1) {
                alert("绑定成功,谢谢!");
                } else if (data = 0) {
                    alert("操作失败,该记录可能已不存在。");
                } else if (data > 1) {
                    alert("错误,有多条记录被删除。");
                }
            },
            error: function (textStatus) {
                alert("数据加载失败!!!");
            }
});





=================================================
@RequestMapping(value = "/index")
public void index(@RequestParam(value = "alarm", required = false) String alarm , Model model) {////没有传入此参数也可以进入方法,利用这点可以区分
一些不同的操作
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics