在开发中,路径里面带参数的情况很少,但遇到了还要写,备记一下。
前端页面发送请求:
function backdata(){
window.location.href="${pageContext.request.contextPath}/auth/queryAuthhospitalcity?id=10&orgLevel=2&signature="+signature;
}
后端直接来例子吧,一目了然:
@GetMapping("/authHospitalEnd/{id}/{orgLevel}/{signature}")
public ModelAndView authHospitalEnd(@PathVariable("id") Integer id,@PathVariable("orgLevel") Integer orgLevel,@PathVariable("signature") String signature){
Assert.notNull(id, "用户账号id不能为空");
Assert.notNull(orgLevel, "级别不能为空");
Assert.isTrue(!StringUtils.isEmpty(signature), "签名不能为空");// todo 接口参数校验,针对String类型
HttpSession session = super.getSession();
UserLoginVO userLoginVO = (UserLoginVO) super.getCurrentUser(signature);
ModelAndView view = new ModelAndView();
Long accId = userLoginVO.getId();
view.addObject("accId", accId);
List<BaseOrgInfoBO> boList = baseOrgInfoService.getAllCityBOList(id, orgLevel);
List<BaseOrgInfoVO> voList = new ArrayList<>();
if (!CollectionUtils.isEmpty(boList)) {
voList = dozerMapperUtil.mapList(boList, BaseOrgInfoVO.class);
}
view.addObject("list", voList);
view.addObject("signature", signature);
view.setViewName("/auth/hospital/authhospitalend");
return view;
}