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

swnuv
  • 3.8k
这是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.
回复
阅读 2.3k
1 个回答

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

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏