三级联动+回显、多对多添加+回显
实体类
package com. wpx. pojo;
import java. io. Serializable;
public class Area implements Serializable {
private static final long serialVersionUID = 1 L;
Integer id;
int pid;
String name;
public Integer getId ( ) {
return id;
}
public void setId ( Integer id) {
this . id = id;
}
public int getPid ( ) {
return pid;
}
public void setPid ( int pid) {
this . pid = pid;
}
public String getName ( ) {
return name;
}
public void setName ( String name) {
this . name = name;
}
@Override
public String toString ( ) {
return "Area [id=" + id + ", pid=" + pid + ", name=" + name + "]" ;
}
}
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
package com. wpx. pojo;
import java. io. Serializable;
public class Depart implements Serializable {
private static final long serialVersionUID = 1 L;
private Integer id;
private String name;
public Integer getId ( ) {
return id;
}
public void setId ( Integer id) {
this . id = id;
}
public String getName ( ) {
return name;
}
public void setName ( String name) {
this . name = name;
}
@Override
public String toString ( ) {
return "Depart [id=" + id + ", name=" + name + "]" ;
}
}
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
package com. wpx. pojo;
import java. io. Serializable;
import java. util. Date;
import java. util. List;
import org. springframework. format. annotation. DateTimeFormat;
public class Doc implements Serializable {
private static final long serialVersionUID = 5016425494383260711 L;
private Integer id;
private String name;
private String cardno;
@DateTimeFormat ( pattern = "yyyy-MM-dd" )
private Date birthday;
private int provinceId;
private int cityId;
private int countyId;
private int departId;
private int gender;
private String mobile;
@DateTimeFormat ( pattern = "yyyy-MM-dd" )
private Date enterDate;
private String img;
private Area province;
private Area city;
private Area county;
List< Skill> skills;
private Depart depart;
private int age;
private int workAge;
public Integer getId ( ) {
return id;
}
public void setId ( Integer id) {
this . id = id;
}
public String getName ( ) {
return name;
}
public void setName ( String name) {
this . name = name;
}
public String getCardno ( ) {
return cardno;
}
public void setCardno ( String cardno) {
this . cardno = cardno;
}
public Date getBirthday ( ) {
return birthday;
}
public void setBirthday ( Date birthday) {
this . birthday = birthday;
}
public int getProvinceId ( ) {
return provinceId;
}
public void setProvinceId ( int provinceId) {
this . provinceId = provinceId;
}
public int getCityId ( ) {
return cityId;
}
public void setCityId ( int cityId) {
this . cityId = cityId;
}
public int getCountyId ( ) {
return countyId;
}
public void setCountyId ( int countyId) {
this . countyId = countyId;
}
public int getDepartId ( ) {
return departId;
}
public void setDepartId ( int departId) {
this . departId = departId;
}
public int getGender ( ) {
return gender;
}
public void setGender ( int gender) {
this . gender = gender;
}
public String getMobile ( ) {
return mobile;
}
public void setMobile ( String mobile) {
this . mobile = mobile;
}
public Date getEnterDate ( ) {
return enterDate;
}
public void setEnterDate ( Date enterDate) {
this . enterDate = enterDate;
}
public String getImg ( ) {
return img;
}
public void setImg ( String img) {
this . img = img;
}
public Area getProvince ( ) {
return province;
}
public void setProvince ( Area province) {
this . province = province;
}
public Area getCity ( ) {
return city;
}
public void setCity ( Area city) {
this . city = city;
}
public Area getCounty ( ) {
return county;
}
public void setCounty ( Area county) {
this . county = county;
}
public List< Skill> getSkills ( ) {
return skills;
}
public void setSkills ( List< Skill> skills) {
this . skills = skills;
}
public Depart getDepart ( ) {
return depart;
}
public void setDepart ( Depart depart) {
this . depart = depart;
}
public int getAge ( ) {
return age;
}
public void setAge ( int age) {
this . age = age;
}
public int getWorkAge ( ) {
return workAge;
}
public void setWorkAge ( int workAge) {
this . workAge = workAge;
}
@Override
public String toString ( ) {
return "Doc [id=" + id + ", name=" + name + ", cardno=" + cardno + ", birthday=" + birthday + ", provinceId="
+ provinceId + ", cityId=" + cityId + ", countyId=" + countyId + ", departId=" + departId + ", gender="
+ gender + ", mobile=" + mobile + ", enterDate=" + enterDate + ", img=" + img + ", province=" + province
+ ", city=" + city + ", county=" + county + ", skills=" + skills + ", depart=" + depart + ", age=" + age
+ ", workAge=" + workAge + "]" ;
}
}
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
package com. wpx. pojo;
public class DocVo extends Doc {
private static final long serialVersionUID = 1 L;
int page= 1 ;
int pageSize= 10 ;
public int getPage ( ) {
return page;
}
public void setPage ( int page) {
this . page = page;
}
public int getPageSize ( ) {
return pageSize;
}
public void setPageSize ( int pageSize) {
this . pageSize = pageSize;
}
@Override
public String toString ( ) {
return "DocVo [page=" + page + ", pageSize=" + pageSize + "]" ;
}
}
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
package com. wpx. pojo;
import java. io. Serializable;
public class Skill implements Serializable {
private Integer id;
private String name;
public Integer getId ( ) {
return id;
}
public void setId ( Integer id) {
this . id = id;
}
public String getName ( ) {
return name;
}
public void setName ( String name) {
this . name = name;
}
@Override
public String toString ( ) {
return "Skill [id=" + id + ", name=" + name + "]" ;
}
}
service
package com. wpx. service;
import java. util. List;
import com. github. pagehelper. PageInfo;
import com. wpx. pojo. Area;
import com. wpx. pojo. Depart;
import com. wpx. pojo. Doc;
import com. wpx. pojo. DocVo;
import com. wpx. pojo. Skill;
public interface DocService {
PageInfo< Doc> list ( DocVo docVo) ;
int add ( Doc doc) ;
int update ( Doc doc) ;
int del ( int [ ] ids) ;
Doc getById ( int id) ;
List< Area> listArea ( int pid) ;
List< Skill> listSkills ( ) ;
List< Depart> listDepart ( ) ;
}
dubbo服务
package com. wpx;
import java. io. IOException;
import org. springframework. context. support. ClassPathXmlApplicationContext;
public class StartDocService {
public static void main ( String[ ] args) throws IOException {
System. out. print ( "服务启动。。。。。。" ) ;
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext ( "classpath:applicationContext-dubbo-provider.xml" ,
"classpath:applicationContext-dao.xml" ) ;
System. out. print ( "服务启动 ok" ) ;
System. in. read ( ) ;
}
}
Dao接口
package com. wpx. dao;
import java. util. List;
import org. apache. ibatis. annotations. Param;
import com. wpx. pojo. Area;
import com. wpx. pojo. Depart;
import com. wpx. pojo. Doc;
import com. wpx. pojo. DocVo;
import com. wpx. pojo. Skill;
public interface DocDao {
List< Doc> list ( DocVo docVo) ;
int add ( Doc doc) ;
int addDocSkill ( @Param ( "docId" ) int docId, @Param ( "skillId" ) int skillId) ;
List< Depart> listDepart ( ) ;
Doc getById ( int id) ;
List< Skill> listSkills ( ) ;
int delDoc ( int [ ] ids) ;
List< Area> listAea ( int pid) ;
int delDocSkillByDoc ( int . . . ids) ;
int udate ( Doc doc) ;
}
service实现类
package com. wpx. service. impl;
import java. util. List;
import org. apache. dubbo. config. annotation. Service;
import org. springframework. beans. factory. annotation. Autowired;
import com. github. pagehelper. PageHelper;
import com. github. pagehelper. PageInfo;
import com. wpx. dao. DocDao;
import com. wpx. pojo. Area;
import com. wpx. pojo. Depart;
import com. wpx. pojo. Doc;
import com. wpx. pojo. DocVo;
import com. wpx. pojo. Skill;
import com. wpx. service. DocService;
@Service ( interfaceClass= DocService. class )
public class DocServiceImpl implements DocService {
@Autowired
DocDao docDao;
@Override
public PageInfo< Doc> list ( DocVo docVo) {
PageHelper. startPage ( docVo. getPage ( ) , docVo. getPageSize ( ) ) ;
return new PageInfo < Doc> ( docDao. list ( docVo) ) ;
}
@Override
public int add ( Doc doc) {
int result = docDao. add ( doc) ;
List< Skill> skills = doc. getSkills ( ) ;
for ( int i = 0 ; i < skills. size ( ) ; i++ ) {
result+= docDao. addDocSkill ( doc. getId ( ) , skills. get ( i) . getId ( ) ) ;
}
return result;
}
@Override
public int update ( Doc doc) {
int result = docDao. udate ( doc) ;
result += docDao. delDocSkillByDoc ( doc. getId ( ) ) ;
List< Skill> skills = doc. getSkills ( ) ;
for ( int i = 0 ; i < skills. size ( ) ; i++ ) {
result+= docDao. addDocSkill ( doc. getId ( ) , skills. get ( i) . getId ( ) ) ;
}
return result;
}
@Override
public int del ( int [ ] ids) {
int result = docDao. delDocSkillByDoc ( ids) ;
result += docDao. delDoc ( ids) ;
return result;
}
@Override
public List< Area> listArea ( int pid) {
return docDao. listAea ( pid) ;
}
@Override
public List< Skill> listSkills ( ) {
return docDao. listSkills ( ) ;
}
@Override
public List< Depart> listDepart ( ) {
return docDao. listDepart ( ) ;
}
@Override
public Doc getById ( int id) {
return docDao. getById ( id) ;
}
}
Mapper
< ? xml version= "1.0" encoding= "UTF-8" ? >
< ! DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
< mapper namespace= "com.wpx.dao.DocDao" >
< ! -- List< Doc> list ( DocVo docVo) ; -- >
< resultMap type= "doc" id= "docMapper" >
< id column= "id" property= "id" > < / id>
< association property= "province" column= "provinceId" select= "findAreaByid" > < / association>
< association property= "city" column= "cityId" select= "findAreaByid" > < / association>
< association property= "county" column= "countyId" select= "findAreaByid" > < / association>
< association property= "depart" column= "departId" select= "findDepartByid" > < / association>
< collection property= "skills" column= "id" select= "findSkillsByDocId" > < / collection>
< / resultMap>
< select id= "list" resultMap= "docMapper" >
select * from tb_doc
< / select>
< select id= "findAreaByid" resultType= "area" >
select * from tb_area where id= #{
value}
< / select>
< select id= "findDepartByid" resultType= "depart" >
select * from tb_depart where id= #{
value}
< / select>
< select id= "findSkillsByDocId" resultType= "skill" >
SELECT s. * from tb_doc_skill ds LEFT JOIN tb_skill s ON s. id= ds. skillId
WHERE ds. docId= #{
value}
< / select>
< ! -- int add ( Doc doc) ; -- >
< insert id= "add" useGeneratedKeys= "true" keyColumn= "id" keyProperty= "id" >
insert into tb_doc ( name, cardno, birthday, provinceId, cityId, countyId, departId, mobile, enterDate, img, gender)
values ( #{
name} , #{
cardno} , #{
birthday} , #{
provinceId} , #{
cityId} , #{
departId} , #{
countyId} , #{
mobile} , #{
enterDate} , #{
img} , #{
gender} )
< / insert>
< ! -- int addDocSkill ( Integer id, Integer id2) ; -- >
< insert id= "addDocSkill" >
insert into tb_doc_skill ( docId, skillId) values ( #{
docId} , #{
skillId} )
< / insert>
< ! -- List< Depart> listDepart ( ) ; -- >
< select id= "listDepart" resultType= "depart" >
select * from tb_depart
< / select>
< ! -- Doc getById ( ) ; -- >
< select id= "getById" resultMap= "docMapper" >
select * from tb_doc where id= #{
value}
< / select>
< ! -- List< Skill> listSkills ( ) ; -- >
< select id= "listSkills" resultType= "skill" >
select * from tb_skill
< / select>
< ! -- int delDoc ( int [ ] ids) ; -- >
< delete id= "delDoc" >
delete from tb_doc where id in
< foreach collection= "array" item= "id" open= "(" close= ")" separator= "," >
#{
id}
< / foreach>
< / delete>
< ! -- List< Area> listAea ( int pid) ; -- >
< select id= "listAea" resultType= "area" >
select * from tb_area where pid= #{
value}
< / select>
< ! -- int delDocSkillByDoc ( int . . . ids) ; -- >
< delete id= "delDocSkillByDoc" >
delete from tb_doc_skill where docId in
< foreach collection= "array" item= "id" open= "(" close= ")" separator= "," >
#{
id}
< / foreach>
< / delete>
< ! -- int udate ( Doc doc) ; -- >
< update id= "udate" >
update tb_doc
set name= #{
name} ,
cardno= #{
cardno} ,
birthday= #{
birthday} ,
provinceId= #{
provinceId} ,
cityId= #{
cityId} ,
countyId= #{
countyId} ,
countyId= #{
countyId} ,
mobile= #{
mobile} ,
enterDate= #{
enterDate} ,
img= #{
img} ,
gender= #{
gender}
where id= #{
id}
< / update>
< / mapper>
Controller类
package com. wpx. controller;
import java. io. IOException;
import java. util. ArrayList;
import java. util. List;
import javax. servlet. http. HttpServletRequest;
import org. apache. dubbo. config. annotation. Reference;
import org. springframework. stereotype. Controller;
import org. springframework. web. bind. annotation. RequestMapping;
import org. springframework. web. bind. annotation. ResponseBody;
import org. springframework. web. multipart. MultipartFile;
import com. wpx. common. FileUtils;
import com. wpx. pojo. Area;
import com. wpx. pojo. Depart;
import com. wpx. pojo. Doc;
import com. wpx. pojo. Skill;
import com. wpx. service. DocService;
@Controller
public class DocController {
@Reference
DocService docService;
@RequestMapping ( "toadd" )
public String toAdd ( HttpServletRequest request) {
List< Area> listProince = docService. listArea ( 0 ) ;
request. setAttribute ( "proinces" , listProince) ;
List< Skill> listSkills = docService. listSkills ( ) ;
request. setAttribute ( "skills" , listSkills) ;
List< Depart> listDepart = docService. listDepart ( ) ;
request. setAttribute ( "departs" , listDepart) ;
return "add" ;
}
@RequestMapping ( "toupdate" )
public String toUpdate ( HttpServletRequest request, int id) {
Doc doc = docService. getById ( id) ;
request. setAttribute ( "doc" , doc) ;
System. out. println ( "doc is " + doc) ;
List< Area> listProince = docService. listArea ( 0 ) ;
request. setAttribute ( "proinces" , listProince) ;
List< Skill> listSkills = docService. listSkills ( ) ;
request. setAttribute ( "skills" , listSkills) ;
List< Depart> listDepart = docService. listDepart ( ) ;
request. setAttribute ( "departs" , listDepart) ;
if ( doc. getProvince ( ) != null) {
List< Area> listcities = docService. listArea ( doc. getProvince ( ) . getId ( ) ) ;
request. setAttribute ( "cities" , listcities) ;
}
if ( doc. getCity ( ) != null) {
List< Area> listcounties = docService. listArea ( doc. getCity ( ) . getId ( ) ) ;
request. setAttribute ( "counties" , listcounties) ;
}
return "update" ;
}
@RequestMapping ( "listChild" )
@ResponseBody
public List< Area> listChild ( HttpServletRequest request, int pid) {
List< Area> listArea = docService. listArea ( pid) ;
return listArea ;
}
@RequestMapping ( "add" )
public String add ( HttpServletRequest request, Doc doc, int [ ] selSkillId, MultipartFile file) {
try {
String path = FileUtils. processFile ( file) ;
doc. setImg ( path) ;
} catch ( IllegalStateException e) {
e. printStackTrace ( ) ;
} catch ( IOException e) {
e. printStackTrace ( ) ;
}
List< Skill> skills= new ArrayList < Skill> ( ) ;
for ( int i = 0 ; i < selSkillId. length; i++ ) {
Skill skill = new Skill ( ) ;
skill. setId ( selSkillId[ i] ) ;
skills. add ( skill) ;
}
doc. setSkills ( skills) ;
System. out. println ( "sadfas" + doc. getGender ( ) ) ;
docService. add ( doc) ;
return "rediect:list" ;
}
@RequestMapping ( "update" )
public String update ( HttpServletRequest request, Doc doc, int [ ] selSkillId, MultipartFile file) {
try {
String path = FileUtils. processFile ( file) ;
doc. setImg ( path) ;
} catch ( IllegalStateException e) {
e. printStackTrace ( ) ;
} catch ( IOException e) {
e. printStackTrace ( ) ;
}
List< Skill> skills= new ArrayList < Skill> ( ) ;
for ( int i = 0 ; i < selSkillId. length; i++ ) {
Skill skill = new Skill ( ) ;
skill. setId ( selSkillId[ i] ) ;
skills. add ( skill) ;
}
doc. setSkills ( skills) ;
docService. update ( doc) ;
return "rediect:list" ;
}
}
添加页面
< % @ page language= "java" contentType= "text/html; charset=UTF-8"
pageEncoding= "UTF-8" % >
< % @ taglib prefix= "c" uri= "http://java.sun.com/jsp/jstl/core" % >
< ! DOCTYPE html>
< html>
< head>
< meta charset= "UTF-8" >
< script type= "text/javascript" src= "${pageContext.request.contextPath}/resource/jquery/jquery-3.4.1.js" > < / script>
< title> 添加< / title>
< / head>
< body>
< form action= "${pageContext.request.contextPath}/add" method= "post" enctype= "multipart/form-data" >
< table>
< tr>
< td> 姓名< / td>
< td> < input name= "name" > < / td>
< / tr>
< tr>
< td> 身份证< / td>
< td> < input name= "cardno" > < / td>
< / tr>
< tr>
< td> 电话< / td>
< td> < input name= "mobile" > < / td>
< / tr>
< tr>
< td> 性别< / td>
< td> < input type= "radio" name= "gender" value= "1" > 男
& nbsp; & nbsp; & nbsp; & nbsp;
< input type= "radio" name= "gender" value= "2" > 女
< / td>
< / tr>
< tr>
< td> 生日< / td>
< td> < input type= "date" name= "birthday" > < / td>
< / tr>
< tr>
< td> 省< / td>
< td>
< select name= "provinceId" id= "provinceId" onchange= "changeSub('provinceId','cityId')" >
< option value= "-1" > -- - 请选择-- - < / option>
< c: forEach items= "${proinces}" var= "p" >
< option value= "${p.id}" > ${
p. name} < / option>
< / c: forEach>
< / select> < / td>
< / tr>
< tr>
< td> 市< / td>
< td>
< select name= "cityId" id= "cityId" onchange= "changeSub('cityId','countyId')" >
< option value= "-1" > -- - 请选择-- - < / option>
< / select> < / td>
< / tr>
< tr>
< td> 县< / td>
< td>
< select name= "countyId" id= "countyId" >
< option value= "-1" > -- - 请选择-- - < / option>
< / select> < / td>
< / tr>
< tr>
< td> 科室< / td>
< td>
< select name= "departId" id= "departId" >
< option value= "-1" > -- - 请选择-- - < / option>
< c: forEach items= "${departs}" var= "d" >
< option value= "${d.id}" > ${
d. name} < / option>
< / c: forEach>
< / select> < / td>
< / tr>
< tr>
< td> 擅长< / td>
< td>
< c: forEach items= "${skills}" var= "s" >
< input type= "checkbox" name= "selSkillId" value= "${s.id}" > ${
s. name} & nbsp; & nbsp; & nbsp; & nbsp;
< / c: forEach>
< / td>
< / tr>
< tr>
< td> 头像< / td>
< td>
< input type= "file" name= "file" >
< / td>
< / tr>
< tr>
< td> 入职日期< / td>
< td> < input type= "date" name= "enterDate" > < / td>
< / tr>
< tr>
< td> < / td>
< td> < button type= "submit" > 提交< / button> < / td>
< / tr>
< / table>
< / form>
< script type= "text/javascript" >
function changeSub ( parId, childId) {
var pid= $( "#" + parId) . val ( ) ;
var childObj = $( "#" + childId)
$. post ( "${pageContext.request.contextPath}/listChild" , {
pid, pid} , function ( data) {
childObj. empty ( ) ;
childObj. append ( '---请选择--- ' )
for ( var i in data) {
childObj. append ( '+ data[ i] . id+ '">' + data[ i] . name+ ' ' )
}
} )
}
< / script>
< / body>
< / html>
修改页面加回显
< % @ page language= "java" contentType= "text/html; charset=UTF-8"
pageEncoding= "UTF-8" % >
< % @ taglib prefix= "c" uri= "http://java.sun.com/jsp/jstl/core" % >
< % @ taglib prefix= "fmt" uri= "http://java.sun.com/jsp/jstl/fmt" % >
< ! DOCTYPE html>
< html>
< head>
< meta charset= "UTF-8" >
< script type= "text/javascript" src= "${pageContext.request.contextPath}/resource/jquery/jquery-3.4.1.js" > < / script>
< title> 修改< / title>
< / head>
< body>
< form action= "${pageContext.request.contextPath}/update" method= "post" enctype= "multipart/form-data" >
< table>
< tr>
< td> 姓名< / td>
< td>
< input type= "hidden" name= "id" value= "${doc.id}" >
< input name= "name" value= "${doc.name}" > < / td>
< / tr>
< tr>
< td> 身份证< / td>
< td> < input name= "cardno" value= "${doc.cardno}" > < / td>
< / tr>
< tr>
< td> 电话< / td>
< td> < input name= "mobile" value= "${doc.mobile}" > < / td>
< / tr>
< tr>
< td> 性别< / td>
< td> < input type= "radio" name= "gender" value= "1" > 男
& nbsp; & nbsp; & nbsp; & nbsp;
< input type= "radio" name= "gender" value= "2" > 女
< / td>
< / tr>
< tr>
< td> 生日< / td>
< td> < input type= "date" name= "birthday" value= ' ' > < / td>
< / tr>
< tr>
< td> 省< / td>
< td>
< select name= "provinceId" id= "provinceId" onchange= "changeSub('provinceId','cityId')" >
< option value= "-1" > -- - 请选择-- - < / option>
< c: forEach items= "${proinces}" var= "p" >
< option value= "${p.id}" ${
doc. province. id== p. id? 'selected' : '' } > ${
p. name} < / option>
< / c: forEach>
< / select> < / td>
< / tr>
< tr>
< td> 市< / td>
< td>
< select name= "cityId" id= "cityId" onchange= "changeSub('cityId','countyId')" >
< option value= "-1" > -- - 请选择-- - < / option>
< c: forEach items= "${cities}" var= "c" >
< option value= "${c.id}" ${
doc. city. id== c. id? 'selected' : '' } > ${
c. name} < / option>
< / c: forEach>
< / select> < / td>
< / tr>
< tr>
< td> 县< / td>
< td>
< select name= "countyId" id= "countyId" >
< option value= "-1" > -- - 请选择-- - < / option>
< c: forEach items= "${counties}" var= "c" >
< option value= "${c.id}" ${
doc. county. id== c. id? 'selected' : '' } > ${
c. name} < / option>
< / c: forEach>
< / select> < / td>
< / tr>
< tr>
< td> 科室< / td>
< td>
< select name= "departId" id= "departId" >
< option value= "-1" > -- - 请选择-- - < / option>
< c: forEach items= "${departs}" var= "d" >
< option value= "${d.id}" > ${
d. name} < / option>
< / c: forEach>
< / select> < / td>
< / tr>
< tr>
< td> 擅长< / td>
< td>
< c: forEach items= "${skills}" var= "s" >
< input type= "checkbox" name= "selSkillId"
< c: forEach items= "${doc.skills}" var= "selSkill" >
< c: if test= "${selSkill.id==s.id}" > checked< / c: if >
< / c: forEach>
value= "${s.id}" > ${
s. name} & nbsp; & nbsp; & nbsp; & nbsp;
< / c: forEach>
< / td>
< / tr>
< tr>
< td> 头像< / td>
< td>
< input type= "file" name= "file" >
< img src= "/pic/${doc.img}" width= "150" height= "150" >
< / td>
< / tr>
< tr>
< td> 入职日期< / td>
< td> < input type= "date" name= "enterDate" value= ' ' > < / td>
< / tr>
< tr>
< td> < / td>
< td> < button type= "submit" > 提交< / button> < / td>
< / tr>
< / table>
< / form>
< script type= "text/javascript" >
function changeSub ( parId, childId) {
var pid= $( "#" + parId) . val ( ) ;
var childObj = $( "#" + childId)
$. post ( "${pageContext.request.contextPath}/listChild" , {
pid, pid} , function ( data) {
childObj. empty ( ) ;
childObj. append ( '---请选择--- ' )
for ( var i in data) {
childObj. append ( '+ data[ i] . id+ '">' + data[ i] . name+ ' ' )
}
} )
}
< / script>
< / body>
< / html>