参数类型 (@Controller层)

 

@RequestMapping(path = "/listPage")
@SuppressWarnings("unchecked")
@BussinessLog(value = "查询财务信息列表", key = "listPage") @ResponseBody
public Object listPage(String condition,Integer adPositionId) {return super.packForBT(result); }
@RequestMapping("/advInfo_update/{advId}")
public ModelAndView goAdvInfoUpdate(@PathVariable Integer advId) {return mv;
}
@RequestMapping("/zyh/{type}")
  public String zyh(@PathVariable(value = "type") int type) throws UnsupportedEncodingException {
    String url = "http://wx.diyfintech.com/zyhMain/" + type;
  }

 

复杂参数,实体类参数

@RequestMapping("/delete")
@ResponseBody
public Object deleteAdv(AdvAdInfo advInfo) {return SUCCESS_TIP;
}

 

springMVC中的注解@RequestParam与@PathVariable的区别

在SpringMVC后台控制层获取参数的方式主要有两种:

一种是request.getParameter("name"),另外一种是用注解@RequestParam直接获取

这里主要讲这个注解 @RequestParam

接下来我们看一下@RequestParam注解主要有哪些参数:

value:参数名字,即入参的请求参数名字,如username表示请求的参数区中的名字为username的参数的值将传入;

required:是否必须,默认是true,表示请求中一定要有相应的参数,否则将报404错误码;

defaultValue:默认值,表示如果请求中没有同名参数时的默认值,例如:

public List<EasyUITreeNode> getItemTreeNode(@RequestParam(value="id",defaultValue="0")long parentI

    @RequestMapping("listcarbrandinfo")
    public ResultEntity listCarBrandInfo(@RequestParam(name = "data", required = true) String data,
            @RequestParam(name = "userid", required = false) Integer userId) {
}

 

转载于:https://www.cnblogs.com/dianzan/p/11244412.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值