使用的是spring,spring mvc,mybatis框架,然后用generatorConfig.xml生成的,所以实体还有dao里面包括映射是一样的 我就不发那块的代码了,controller是自己做的,三表级联,代码如下
1 package com.charmyin.cmstudio.njfu.eat_name.controller; 2 3 import java.util.List; 4 5 import javax.annotation.Resource; 6 7 import org.springframework.stereotype.Controller; 8 import org.springframework.web.bind.annotation.RequestMapping; 9 import org.springframework.web.bind.annotation.RequestMethod; 10 import org.springframework.web.bind.annotation.ResponseBody; 11 12 import com.charmyin.cmstudio.njfu.eat_name.persistence.Eat_nameMapper; 13 import com.charmyin.cmstudio.njfu.eat_name.vo.Eat_name; 14 import com.charmyin.cmstudio.njfu.eat_name.vo.Eat_nameExample; 15 16 @Controller 17 @RequestMapping("/eat") 18 public class Eat_nameController { 19 20 @Resource 21 Eat_nameMapper eat_nameMapper; 22 23 @RequestMapping(value="/index") 24 public String Index(){ 25 return "/njfu/eat/index"; 26 } 27 28 @RequestMapping(method=RequestMethod.POST,value="/name") 29 @ResponseBody 30 public List<Eat_name> getall(){ 31 Eat_nameExample enamee=new Eat_nameExample(); 32 List<Eat_name> list=eat_nameMapper.selectByExample(enamee); 33 return list; 34 } 35 }
1 package com.charmyin.cmstudio.njfu.eat_address.controller; 2 3 import java.util.List; 4 5 import javax.annotation.Resource; 6 7 import org.springframework.stereotype.Controller; 8 import org.springframework.web.bind.annotation.RequestMapping; 9 import org.springframework.web.bind.annotation.RequestMethod; 10 import org.springframework.web.bind.annotation.ResponseBody; 11 12 import com.charmyin.cmstudio.njfu.eat_address.persistence.Eat_addressMapper; 13 import com.charmyin.cmstudio.njfu.eat_address.vo.Eat_address; 14 import com.charmyin.cmstudio.njfu.eat_address.vo.Eat_addressExample; 15 16 @Controller 17 @RequestMapping("/eatadd") 18 public class Eat_addressController { 19 20 @Resource 21 Eat_addressMapper eat_addressMapper; 22 23 @RequestMapping(method=RequestMethod.POST,value="/address") 24 @ResponseBody 25 public List<Eat_address> getadd(String tid){ 26 Eat_addressExample eaddresse=new Eat_addressExample(); 27 eaddresse.or().andTidEqualTo(tid); 28 List<Eat_address> list=eat_addressMapper.selectByExample(eaddresse); 29 return list; 30 } 31 }
1 package com.charmyin.cmstudio.njfu.eat_price.controller; 2 3 import java.util.List; 4 5 import javax.annotation.Resource; 6 7 import org.springframework.stereotype.Controller; 8 import org.springframework.web.bind.annotation.RequestMapping; 9 import org.springframework.web.bind.annotation.RequestMethod; 10 import org.springframework.web.bind.annotation.ResponseBody; 11 12 import com.charmyin.cmstudio.njfu.eat_price.persistence.Eat_priceMapper; 13 import com.charmyin.cmstudio.njfu.eat_price.vo.Eat_price; 14 import com.charmyin.cmstudio.njfu.eat_price.vo.Eat_priceExample; 15 16 @Controller 17 @RequestMapping("/eatp") 18 public class Eat_priceController { 19 20 @Resource 21 Eat_priceMapper eat_priceMapper; 22 23 @RequestMapping(method=RequestMethod.POST,value="/price") 24 @ResponseBody 25 public List<Eat_price> getprice(String uid){ 26 Eat_priceExample epricee=new Eat_priceExample(); 27 epricee.or().andUidEqualTo(uid); 28 List<Eat_price> list=eat_priceMapper.selectByExample(epricee); 29 return list; 30 } 31 }
接下来是它指向的jsp
1 <%@ page language="java" contentType="text/html; charset=utf-8" 2 pageEncoding="utf-8"%> 3 <%@ taglib uri="/WEB-INF/tlds/cmstudio.tld" prefix="cmstudio"%> 4 5 <!DOCTYPE html> 6 <html> 7 <head> 8 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 9 <title>${application_name_cn}</title> 10 11 12 <cmstudio:htmlBase /> 13 14 <!--Start importing the jquery files --> 15 <cmstudio:importJsCss name="jquery" version="${jquery_version}" /> 16 <!--End import the jquery files --> 17 <!--Start importing the jeasyui files --> 18 <cmstudio:importJsCss name="jeasyui" version="${jeasyui_version}" /> 19 </head> 20 <body> 21 <input id="test1" class="easyui-combobox" 22 data-options=" 23 url:'eat/name', 24 valueField:'id', 25 textField:'name', 26 method:'post', 27 editable:false, 28 panelHeight:'auto', 29 onSelect:function(rec){ 30 var id=rec.id; 31 $('#test2').combobox('clear'); 32 $('#test2').combobox('reload','eatadd/adddress?tid='+id); 33 } 34 "> 35 <input id="test2" class="easyui-combobox" 36 data-options=" 37 method:'post', 38 editable:false, 39 panelHeight:'auto', 40 onSelect:function(rec){ 41 var id=rec.id; 42 $('#test3').combobox('clear'); 43 $('#test3').combobox('reload','eatp/price?uid='+id); 44 } 45 "> 46 <input id="test3"> 47 </body> 48 <script type="text/javascript"> 49 $('#test2').combobox({ 50 valueField:'id', 51 textField:'address', 52 }); 53 54 $('#test3').combobox({ 55 valueField:'id', 56 textField:'price', 57 method:'post', 58 editable:false, 59 panelHeight:'auto', 60 }); 61 </script> 62 <style type="text/css"> 63 </style> 64 </body> 65 </html>
我以前做的跟这个一样的项目是可以正常运行的.但是这个项目却无法展开第二个跟第三个下拉框,下面是以前运行的截图跟现在的截图
这张图是以前的,可以运行
这张图是现在的,第二个框点了都不展开
看着没啥错误,是不是铁观音没有二级选项
找到错误了呐...是sql没设计好.id跟tid对不上所以它找不到呢...