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

页面代码

<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. Word Reversal(string)

    For each list of words, output a line with each word reversed without changing the order of the word ...

  2. postman传入cookie的三种方式

    1.直接在环境变量里面设置 2.在登录接口的tests,把返回值的cookie设置为全局变量 3.直接在cookie里面传入

  3. PHP程序员要掌握哪些技术

    PHP程序员要掌握哪些技术 第一阶段: (PHP+MySQL核心编程)面向对象编程MySQL数据库,MySQL的优化细节.HTTP协议,http也是我们web开发的基石.对我们了解PHP底层机制有很大 ...

  4. 【JVM】JVM中的垃圾回收算法

    1.标记 -清除算法 "标记-清除"(Mark-Sweep)算法,如它的名字一样,算法分为"标记"和"清除"两个阶段:首先标记出所有需要回收 ...

  5. POJ 1679 判断最小树是否唯一

    题意:       给你一个图,问你最小树是否唯一,唯一则输出最小数的权值,不唯一输出Not Unique! 思路:      题目问的是最小树是否唯一,其实也就是在问次小树是否等于最小树,如果等于则 ...

  6. 如何让c语言使用结构体近似模拟c++中的类

    如今统治市场的主流编程语言,如c++,java,大都是面向对象类型的编程语言. 而众所周知,c语言是面向过程的编程语言,但是它拥有一个类似于类的结构,叫做结构体,主要的区别在于结构体无法定义函数. 因 ...

  7. SMTP、POP3和IMAP邮件协议

    目录 SMTP POP IMAP 总结 DNS记录中的MX记录 今天入职第一天,公司让配置个人的内网.外网邮箱,这可把我给搞晕了,本来以前就对邮箱这块不是很了解,平时也不怎么用邮箱,顶多有个QQ邮箱而 ...

  8. net -snmp 的监控策略

    yum install net-snmp net-snmp-utils -y vim /etc/snmp/snmpd.conf 最后添加:rocommunity nmap 192.168.1.0/24 ...

  9. 十进制转n进制

    #include <stdio.h> #include <stdlib.h> #define OK 1 #define ERROR 0 #define TRUE 1 #defi ...

  10. php实现微信推送消息

    一.<?phpnamespace Org\Weixin;class OrderPush{ protected $appid; protected $secrect; protected $acc ...