这是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