首页 新闻 会员 周边 捐助

request.getParameter获取不到页面的值

0
悬赏园豆:10 [已关闭问题] 关闭于 2015-12-23 14:35
 @RequiresPermissions("pis:specimenCutting:edit")
    @RequestMapping(value = "cassettePrintChooseRedirect")
    public String cassettePrintChooseRedirect(HttpServletRequest request,
            Model model
            //@RequestParam(value = "channel",required = false)Integer channel
            ) {
        
        Long id = Long.parseLong(request.getParameter("id"));
        Accession accession = accessionService.get(id);
        model.addAttribute("accession", accession);
  
        return "frames/cassettePrintChoose";
    }

    /**
     * 打印包埋盒
     * 
     * @param datas
     * @param model
     * @return
     * @throws Exception
     *             ,
     */

    // com.lumanmed.pathinfo.modules.pis.service.impl; 本地文件服务

    @RequiresPermissions("pis:specimenCutting:edit")
    @RequestMapping(value = "print")
    @SuppressWarnings("all")
    public String print(
            @RequestParam(required = false, value = "datas") String datas,
            @RequestParam(required = false,value = "channel")String channel,
            Model model, HttpServletRequest request,
            HttpServletResponse response) throws Exception, IOException {

        
        String[] nos = datas.split(";");
        // JSONArray jsonArray=new JSONArray(datas);
        StringBuilder sb = new StringBuilder();

        for (String no : nos) {
            if (StringUtils.isNotBlank(no)) {
                sb.append(no + "\r\n");
                
            }
        }
        System.out.println(request.getParameter("channel"));
        
        
        //String channels = request.getParameter("channel");
           
           System.out.println("通道类型:"+channel);
        
        
        
        response.getWriter().write(sb.toString());

     

        response.addHeader("Content-Disposition",
                "attachment;filename=download.txt");
        response.setContentType("application/octet-stream; charset=utf-8");
        response.getWriter().close();
        
        
        System.out.println("写入成功");
        return "/modules/pis/specimenCuttingPrint";
       
    }

    @RequestMapping(value = "getFrozenCuttingByNo")
    @ResponseBody
    public SpecimenCutting getFrozenCuttingByNo(
            @RequestParam(value = "no") String no,
            HttpServletRequest request
            ) {
        
        
        String fsNo = "FS" + no.substring(no.indexOf("-"));
        Accession acc = accessionService.getAccessionLike(fsNo + "%");
        
        
        if (acc == null) {
            return null;
        } else {
            return acc.getSpecimenCutting();
        }

    }
<div>
        
        <form id="autoform" name="autoform" action="${ctx}/pis/specimenCutting/print" method="get" >
        

 <script language="JavaScript">

setTimeout("autoform.submit();",0);

</script> 
        
        <label>请选择包埋盒通道:</label>
        <!-- onchange="document.getElementById("sel_text").value=options[selectedIndex].text" 
        onchange="testselection()"
         -->
         
        <select  required="required" id="channel" name="channel" onclick="testselection(channel)">
        <option selected="selected" >--请选择--</option>
        <option id="white" value="1" >白色</option>
        <option id="red" value="2" >红色</option>
        <option id="blue" value="3" >蓝色</option>

        </select>
        
        
        <input type="submit" value="获取selectvalue值" onclick="testdata()" />
        
        <!-- <input type="hidden" id="sel_text"> 
        
         -->
<input type="submit" style="display: none;" > 
        
        </form>
        
        </div>
    
         <script type="text/javascript">
        
        function testselection(optionval){
            
            $("#channel").change(function(){
                
                //带回value值
                 //var optionval=$("#channel").val(); 
                
                //选中的值
                var optionval = $('#channel option:selected') .val();
                
                
            })
            
        }
        
        </script>
        
        <script type="text/javascript">
        
        function testdata(){
            
            alert($("#channel").val());
            
        }
        
        </script>
        
    </div>

测试过js可以正常获取到值,就是controller获取不到值。channel为null,急解。拜托各位哥哥姐姐帮忙解答下。

玉儿滢心的主页 玉儿滢心 | 初学一级 | 园豆:187
提问于:2015-07-09 16:39
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册