@RequestParam(required = true),@RequestParam(required = true)
今天在页面请求后台的时候遇到了一个问题,请求不到后台
页面代码
<li>
<a href="javascript:void(0);" class="indicator statistics">
<span class="icon icon-statistics"></span>
统计中心
<span class="allow"></span>
</a>
<ul class="submenu">
<li><a href="${ctx }/views/material/BrandGrade_statistics_page">材价库统计</a></li>
<li><a href="${ctx }/views/material/BrandGrade_statistics_page">品牌库统计</a></li>
<li><a href="${ctx }/views/document/documentList/document_statistics_page">文档库统计</a></li>
<li><a href="${ctx }/views/material/BrandGrade_statistics_page">员工贡献榜</a></li>
</ul>
</li>
后台代码
/**
* 文档库页面
*/
@RequestMapping(value = "/document_statistics_page", produces = { WebConstant.WEB_CHARSET })
public String document_statistics_page(@RequestParam("isprivatedoc") String isprivatedoc,
HttpServletRequest request,HttpServletResponse response,Model model) throws Exception {
List<Document> getSourceList = documentListService.getSource();
List<Document> getCategoryList = documentListService.getCategory();//一级分类
Map<String, List<Map<String, String>>> thirdcategoryList = Maps.newConcurrentMap();
if (null != getCategoryList && !getCategoryList.isEmpty()) {
List<Document> getSubCategoryList = documentListService.getSubCategory();//二级级分类
for (Document category : getCategoryList) {
List<Map<String, String>> nodeList = new ArrayList();
String id = category.getId()+"";
for (Document category2 : getSubCategoryList) {
if(category2.getCategoryid()!=null&&id.equals(category2.getCategoryid())){
Map<String, String> subMap = new HashMap<String,String>();
subMap.put("id", category2.getSubcategoryid());
subMap.put("category", category2.getCategoryName());
nodeList.add(subMap);
}
}
thirdcategoryList.put(id, nodeList);
}
}
model.addAttribute("getCategoryList", getCategoryList);
model.addAttribute("thirdcategoryList", thirdcategoryList);
model.addAttribute("getSourceList", getSourceList);
return "/statistics/document_statistics1";
}
后来找到了是使用SpringMVC注解@RequestParam的问题:
使用SpringMVC注解@RequestParam(value="XXX",required=false)时需要注意的问题
@RequestParam(value = what required = true)
void test(int what){};
这个是传参 当他为false 时 使用这个注解可以不传这个参数 true时必须传
required默认值是true
原因是我在页面的 href没有带后台要到请求的参数。
@RequestParam(required = true),@RequestParam(required = true)的更多相关文章
- spring mvc 绑定参数据默认值,是否必传,(RequestParam(value="id",defaultValue="1",required=true) )
@RequestMapping(value = "/detail", method = RequestMethod.GET) public String newDetail(@Re ...
- @RequestMapping映射请求,@PathVariable,@RequestParam,@RequestHeader的使用
1.@RequestMapping Spring MVC 使用 @RequestMapping 注解为控制器指定可以处理哪些 URL 请求,在控制器的类定义及方法定义处都可标注. @RequestMa ...
- @PathVariable,@RequestParam, @RequestBody
https://www.cnblogs.com/guoyinli/p/7056146.html https://www.cnblogs.com/zeroingToOne/p/8992746.html ...
- @RequestBody对象为空,异常Required request body is missing
1.异常 org.springframework.http.converter.HttpMessageNotReadableException: Required request body is mi ...
- SpringMVC中通过@ResponseBody返回对象,Js中调用@ResponseBody返回值,统计剩余评论字数的js,@RequestParam默认值,@PathVariable的用法
1.SpringMVC中通过@ResponseBody.@RequestParam默认值,@PathVariable的用法 package com.kuman.cartoon.controller.f ...
- SpringBoot实战(四)获取接口请求中的参数(@PathVariable,@RequestParam,@RequestBody)
上一篇SpringBoot实战(二)Restful风格API接口中写了一个控制器,获取了前端请求的参数,现在我们就参数的获取与校验做一个介绍: 一:获取参数 SpringBoot提供的获取参数注解包括 ...
- @RequestBody对象为空,异常Required request body is missing错误解决
1.异常 org.springframework.http.converter.HttpMessageNotReadableException: Required request body is mi ...
- 问题:两个对象值相同(x.equals(y) == true),但是可能存在hashCode不同吗?
面试官的考察点 这道题仍然是考察JVM层面的基本知识,面试官认为,基本功扎实,才能写出健壮性和稳定性很高的代码. 涉及到的技术知识 (x.equals(y)==true),这段代码,看起来非常简单,但 ...
- [ jquery 过滤器 hasClass(class) ] 此方法用于在选择器的基础之上检查当前的元素是否含有某个特定的类,如果有,则返回true
此方法用于在选择器的基础之上检查当前的元素是否含有某个特定的类,如果有,则返回true 实例: <!DOCTYPE html> <html lang='zh-cn'> < ...
随机推荐
- POJ2528线段树段更新逆序异或(广告牌)
题意: 可以这样理解,有一条直线,然后用n条线段去覆盖,最后问全部都覆盖完之后还有多少是没有被完全覆盖的. 思路: 一开始想的有点偏,想到起点排序,然后..失败了,原因是忘记了题目 ...
- 如何在jQuery的Ajax调用后管理一个重定向请求
1 success:function(data){ 2 if(data.xx == "xx") 3 { 4 //code... 5 window.location.href =&q ...
- XCTF-ics-04
ics-04 题目描述 工控云管理系统新添加的登录和注册页面存在漏洞,请找出flag. 解题过程 拿dirsearch扫一波,没有什么有用的东西 注册个账号,登陆被提示普通用户登录成功,没什么用 登陆 ...
- 【JavaScript】JS从入门到深入(复习查漏向
[JavaScript]JS从入门到深入(复习查漏向 pre 精细得学过一遍JS后才发现,原来之前CTF中有些nodejs的题目以及一些游戏题的payload就变得很好理解了. 基础知识 ECMASc ...
- 【转】docker打包python应用
转自https://www.cnblogs.com/shenh/p/9518343.html 一.前言 容器使用沙箱机制,互相隔离,优势在于让各个部署在容器的里的应用互不影响,独立运行,提供更高的安全 ...
- shell 脚本中常用的内置变量
在 Bash 解释器中,内置了许多变量,这些变量的功能是解释器自带的,我们在编写shell脚本时如果能灵活的使用它们,对脚本的编写效率以及差错大有帮助, 下面一一介绍这些变量 $FUNCNAME.$L ...
- Asp.NetCore Web开发之路由
接着讲asp.net core web开发,这节讲路由系统(Route). 在asp.net core中通过路由来将请求映射到对应的action,主要用到两个中间件,UseRouting()和UseE ...
- Java学习之jackson篇
Java学习之jackson篇 0x00 前言 本篇内容比较简单,简单记录. 0x01 Json 概述 概述:JSON(JavaScript Object Notation, JS 对象简谱) 是一种 ...
- 使用 vue3 的自定义指令给 element-plus 的 el-dialog 增加拖拽功能
element-plus 提供的 el-dialog 对话框功能非常强大,只是美中不足不能通过拖拽的方式改变位置,有点小遗憾,那么怎么办呢?我们可以通过 vue 的自定义指令来实现一个可以拖拽的对话框 ...
- Vue3响应式系统api 之 ref reactive
reactive 接收一个普通对象然后返回该普调对象的响应式代理.等同于2.x的 Vue.observable() Vue3中响应数据核心是 reactive , reactive 中的实现是由 P ...