SSM + AJAX + JSON 动态下拉框

前台页面

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>



无标题页


















































  添加单元信息
  所属项目:
 
 
  所属楼栋:
 
 
  单元编号:
 
  房间数量:
 
   
   



 






后台接值

@ResponseBody
@RequestMapping("/selectProject.do")
   public String selectProject(HttpServletRequest request,HttpServletResponse response){
   Integer projectid = Integer.parseInt(request.getParameter("projectid"));
System.out.println("projectid"+projectid);
Map map1 = new HashMap();
map1.put("projectid", projectid);
List complexList=complexService.selectByProjectId(map1);
   JSONObject json = new JSONObject();
   json.put("complexList", complexList);
   PrintWriter out;
try {
out = response.getWriter();
out.println(json.toString()); 
   out.close(); 
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}

注意:需要导入json  jar   包

你可能感兴趣的:(SSM + AJAX + JSON 动态下拉框)