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

页面代码

<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. 使用MyQR模块生成二维码

    一.介绍 MyQR 模块是 python 的一个外部库,能够将文本或网址转为二维码,扫了之后就能查看文本或跳转到相应网站. 它是一个外部库,需要导入: pip install -i https://p ...

  2. hdu1722 切蛋糕

    题意:CakeTime Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Subm ...

  3. 写复杂的json方法

    <?php for($j=0; $j< 30; $j++) { $Axis[$j] = "a"; } $data['xAxis']= $Axis; for($i=0; ...

  4. java之泛型的使用

    在java中,普通的类和方法只能用具体的类型,这对代码的限制很大,代码的可重用性大大降低. 那么如何才能让同一个类和方法使用不同类型的对象呢?在接触泛型之前我们可能会想到通过类型转换的方法来实现. p ...

  5. idea下不能运行main 函数

    解决办法: 需要修改.idea/workspace.xml 在<component name="PropertiesComponent">里添加<property ...

  6. 什么是 Mock 测试?

    什么是 Mock? 作为动词,Mock 是模拟.模仿的意思. 作为名词,Mock 是能够模仿真实对象行为的模拟对象. 那么,在软件测试中,Mock 所模拟的对象是什么呢? 模拟的是 SUT(Syste ...

  7. HDU - 3347 Calculate the expression — 模拟 + map存变量

    传送门 题意:从输入开始,1.输入样例数:2.然后输入一组样例中的行数n:3.前n-1行为定义变量(之间使用空格隔开),只需要map存进去就可以了(这里有覆盖的情况,故使用mp["s&quo ...

  8. 通过CRM系统改变传统工作模式

    在现在这个互联网时代,同行业的竞争越发激烈,因此许多企业都选择使用CRM来提高企业的销售业绩.CRM客户关系管理系统是能够优化企业的销售流程.维护良好的客户关系.对销售流程进行管理的强大工具.但是很多 ...

  9. Go - 开箱即用,WEB 界面一键安装,没有项目经验,可以拿这个练手

    安装界面 启动程序之后,会在浏览器中自动打开安装界面. 因为程序会使用到 Redis 和 MySQL,所以安装前请输入 Redis.MySQL 配置信息,点击初始化按钮,会将用到的数据表和默认数据进行 ...

  10. .Net 中的 string、String、StringBuffer 内存处理性能 和 应用场景

    body { font-family: Segoe UI, SegoeUI, Helvetica Neue, Helvetica, Arial, sans-serif } code { color: ...