前台提交的代码,在后台通过属性注入不进去的问题
前台表单代码:
<form id="editForm" method="post">
<table>
<tr>
<td><input class="easyui-textbox" hidden="true" type="text" name="dep.uuid" data-options="required:true"></input></td>
</tr>
<tr>
<td>部门名称:</td>
<td><input class="easyui-textbox" type="text" name="dep.name" data-options="required:true"></input></td>
</tr>
<tr>
<td>部门联系电话:</td>
<td><input class="easyui-textbox" type="text" name="dep.tele" data-options="required:true"></input></td>
</tr>
<tr>
<td>
<button id="editBtn" type="button" class="easyui-linkbutton">编辑</button>
<button id="clearBtn" type="button" class="easyui-linkbutton" onclick="clearForm('editForm')">重置</button>
</td>
</tr>
</table>
</form>
<struts>
<package name="erp" extends="struts-default" namespace="/">
<action name="depAction_*" class="depAction" method="{1}"></action>
</package>
</struts>
depAction里面定义的dep的属性驱动以及add方法
//属性驱动
private Dep dep;
public void setDep(Dep dep) {
this.dep = dep;
}
/**
* 添加部门
*/
public void add() {
System.out.println(dep.getName() +"---"+dep.getTele());
try {
depBiz.add(dep);
returnOptionMessage(true, "添加成功!");
} catch (Exception e) {
returnOptionMessage(false, "添加失败");
e.printStackTrace();
}
}
//部门的实体类
public class Dep {
private Long uuid; //部门ID
private String name; //部门名称
private String tele; //部门电话
public Long getUuid() {
return uuid;
}
public void setUuid(Long uuid) {
this.uuid = uuid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTele() {
return tele;
}
public void setTele(String tele) {
this.tele = tele;
}