今天在页面请求后台的时候遇到了一个问题,请求不到后台

页面代码

<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)的更多相关文章

  1. spring mvc 绑定参数据默认值,是否必传,(RequestParam(value="id",defaultValue="1",required=true) )

    @RequestMapping(value = "/detail", method = RequestMethod.GET) public String newDetail(@Re ...

  2. @RequestMapping映射请求,@PathVariable,@RequestParam,@RequestHeader的使用

    1.@RequestMapping Spring MVC 使用 @RequestMapping 注解为控制器指定可以处理哪些 URL 请求,在控制器的类定义及方法定义处都可标注. @RequestMa ...

  3. @PathVariable,@RequestParam, @RequestBody

    https://www.cnblogs.com/guoyinli/p/7056146.html https://www.cnblogs.com/zeroingToOne/p/8992746.html ...

  4. @RequestBody对象为空,异常Required request body is missing

    1.异常 org.springframework.http.converter.HttpMessageNotReadableException: Required request body is mi ...

  5. SpringMVC中通过@ResponseBody返回对象,Js中调用@ResponseBody返回值,统计剩余评论字数的js,@RequestParam默认值,@PathVariable的用法

    1.SpringMVC中通过@ResponseBody.@RequestParam默认值,@PathVariable的用法 package com.kuman.cartoon.controller.f ...

  6. SpringBoot实战(四)获取接口请求中的参数(@PathVariable,@RequestParam,@RequestBody)

    上一篇SpringBoot实战(二)Restful风格API接口中写了一个控制器,获取了前端请求的参数,现在我们就参数的获取与校验做一个介绍: 一:获取参数 SpringBoot提供的获取参数注解包括 ...

  7. @RequestBody对象为空,异常Required request body is missing错误解决

    1.异常 org.springframework.http.converter.HttpMessageNotReadableException: Required request body is mi ...

  8. 问题:两个对象值相同(x.equals(y) == true),但是可能存在hashCode不同吗?

    面试官的考察点 这道题仍然是考察JVM层面的基本知识,面试官认为,基本功扎实,才能写出健壮性和稳定性很高的代码. 涉及到的技术知识 (x.equals(y)==true),这段代码,看起来非常简单,但 ...

  9. [ jquery 过滤器 hasClass(class) ] 此方法用于在选择器的基础之上检查当前的元素是否含有某个特定的类,如果有,则返回true

    此方法用于在选择器的基础之上检查当前的元素是否含有某个特定的类,如果有,则返回true 实例: <!DOCTYPE html> <html lang='zh-cn'> < ...

随机推荐

  1. 三. 初步认识Eureka注册中心

    Eureka Eureka是Netflix公司出品,英文直译:发现了,找到了! 认识Eureka (一)首先我们来解决第一问题,服务的管理. Ⅰ.早期开发模式中出现的问题 再早期开发时业务时,首先模块 ...

  2. 1079 Total Sales of Supply Chain

    A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...

  3. new word

    strategy: a plan of action or policy designed to achieve a major or overall aim.

  4. Oracle 数据库裸设备扩容处理

    前段时间,我管理的一台Oracle数据库表空间容量不足了,由于本人以前没有接触过Oracle的使用所以,就自己查资料来研究如何扩容,网上的文档多数都是在物理机上扩容,而偏偏我的数据文件是存储在裸设备上 ...

  5. 本地计算机上的Apple Mobile Device服务启动后停止。某些服务在未由其他服务或程序使用时将自动停止

    解决办法:1.开始--运行--regedit.exe,打开注册表编辑器,删除以下两个键: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Wi ...

  6. python-内置函数-文件操作

    文件操作 用的最多的就是r+,w+和a+都有局限性 w+是先清空,然后再写,之后再读 a+是无论如何调整指针位置,写时都在文件最后追加 而r+可以通过调整指针位置来确定写入的位置 文件操作之with处 ...

  7. 变分贝叶斯学习(variational bayesian learning)及重参数技巧(reparameterization trick)

    摘要:常规的神经网络权重是一个确定的值,贝叶斯神经网络(BNN)中,将权重视为一个概率分布.BNN的优化常常依赖于重参数技巧(reparameterization trick),本文对该优化方法进行概 ...

  8. 算法学习笔记1语法 (C++组)持续更新

    关于 #include <cstdio> 包含printf();和scanf(); c++中printf.scanf比cout.cin效率高很多 算法题里cin.cout可能超时,虽然可以 ...

  9. Vulkan移植GPUImage(五)从P到Z的滤镜

    现aoce_vulkan_extra把GPUImage里从P到Z的大部分滤镜用vulkan的ComputeShader实现了,也就是最后一部分的移植,整个过程相对前面来说比较简单,大部分我都是直接复制 ...

  10. ELK 在 MacOS( Big Sur) 上安装与配置步骤

    ELK学习笔记 - 安装篇 目录 ELK学习笔记 - 安装篇 1. ElasticSearch 1.1 发展历史及现状 1.2 ElasticSearch 的安装 2. Logstash 2.1 Lo ...