javascript - ajax级联操作的时候,总是报这个错误

查看:94
本文介绍了javascript - ajax级联操作的时候,总是报这个错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

这是js部分
$('#yh_id').change(function(){    
                $.ajax({    
        url: '<%=basePath%>admin/cyd/con.html?id=' + $('#yh_id').val()+'&name='+new Date().getTime(),
        dataType: 'json',
        success : function(data){
        for(var j=0;j<3;j++){
            $('#yp_id').empty();
            $('#yp_id').append('<option value="-1">请选择</option>');
            $('#cs_id').empty();
            $('#cs_id').append('<option value="-1">请选择</option>');
            $('#sb_id').empty();
            $('#sb_id').append('<option value="-1">请选择</option>');
            for(var i = 0; i< data.length;i++){
                $('#yp_id').append('<option value="' + data[i].id + '">' + decodeURI(data[i].name) + '</option>');
            }
            }
            }
        })
        });
这是后台Java
 @RequestMapping(value = "/con")
         public void con(HttpServletRequest request, HttpServletResponse response, String id,String name) throws SQLException, IOException{
             
             ICommonDao daoyp = DBUtil.getDao();
            String sqlyp ="select b.* from wlpt_yh_yp a join wlpt_jy_yp b on a.yp_id =b.id " +
                    "WHERE b.`status` = 0 and a.yh_id= '"+id+"'";
            List<wlpt_jy_yp> Listyp= null;
            try {
                Listyp = daoyp.queryBusinessObjs(wlpt_jy_yp.class,sqlyp);
            } catch (Exception e) {
                
                e.printStackTrace();
            }  
             
             String str = "";
             for(wlpt_jy_yp con : Listyp){
                 str += "{ \"id\" : \"" + con.getId() + "\", \"name\" : \"" + URLEncoder.encode(con.getYp_name(), "UTF-8") + "\"},";
                 System.out.println(str);
             }
             
             if(str.endsWith(",")){
                 str = str.substring(0, str.length() - 1);
             }
             str = "[" + str + "]";
             response.getWriter().write(str);
             response.getWriter().close();
         }

这是报的错

org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public void com.qdzq.wlpt.controller.admin.CydController.con(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,java.lang.String,java.lang.String) throws java.sql.SQLException,java.io.IOException]; nested exception is java.lang.IllegalStateException: No parameter name specified for argument of type [java.lang.String], and no parameter name information found in class file either.

解决方案

java入参那里写
@RequestParam("name") String name,@RequestParam("id")String id

这篇关于javascript - ajax级联操作的时候,总是报这个错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆