@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'> < ...
随机推荐
- html书签展示(带搜索)
源代码 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title ...
- 简谈Mysql悲观锁和乐观锁
悲观锁: 其实理解起来非常简单,当数据被外界修改持保守态度,包括自身系统当前的其他事务,以及来自外部系统的事务处理,因此,在整个数据处理过程中,将数据处于锁定状态.悲观锁的实现,往往依靠数据库提供的锁 ...
- PAT 乙级 -- 1003 -- 我要通过!
题目简述 "答案正确"是自动判题系统给出的最令人欢喜的回复.本题属于PAT的"答案正确"大派送 -- 只要读入的字符串满足下列条件,系统就输出"答案正 ...
- 8.PHP图像处理
PHP图像处理 GD2 Jpgraph 创建一个画布: <?php header('content-type:image/gif'); //echo "你好"; ...
- Win64 驱动内核编程-13.回调监控模块加载
回调监控模块加载 模块加载包括用户层模块(.DLL)和内核模块(.SYS)的加载.传统方法要监控这两者加在必须 HOOK 好几个函数,比如 NtCreateSection 和 NtLoadDriver ...
- 每天一道面试题LeetCode 01 -- 两数之和
Two Sum 两数之和 Given an array of integers, find two numbers such that they add up to a specific target ...
- FreeSql之Expression表达式拼接参数扩展
在FreeSql源码中Expression表达式拼接默认最多支持到5个泛型参数,当我们使用表关联比较多的时候,就需要进行扩展. 新建一个类,将命名空间改为System.Linq.Expressions ...
- 一、postman基础
- MzzTxx——博客目录
准备阶段 团队介绍 需求分析 技术规格说明书 功能规格说明书 Alpha 阶段任务分配 团队贡献分分配方案 Scrum Meeting Alpha 2021.04.21 Scrum Meeting 0 ...
- vue3.0API详解
Vue 3.0 于 2020-09-18 发布了,使用了 Typescript 进行了大规模的重构,带来了 Composition API RFC 版本,类似 React Hook 一样的写 Vue, ...