1.數據庫建表、SYS_MODULE掛菜單、給菜單添加權限
2.創建Action、Dao、model、service。。。
3.struts-aqxx.xml配置
<action name="zlaqJczl/*" method="{1}" class="com.tech15.aqxx.action.ZlaqJczlAction">
<result name="*" type="direct">基礎資料</result>
</action>
4.類型、更新週期(使用數據字典)下拉選擇(_add.jsp )
condition屬性 :由相應的數據字典id獲取數據字典項
<tr>
<th width="150">類型:</th>
<td colspan="3">
<mytag:select id="lx" title="請選擇類型" name="lx" sql="basedata" isSql="false" condition="1662" dataType="Long" listKey="name" listValue="name" headerKey="" headerValue="請選擇" checkEmpty="true" checkDesc="類型" />
</td>
</tr>
<tr>
<th width="150">更新週期:</th>
<td colspan="3">
<mytag:select id="gxzq" title="請選擇週期" name="gxzq" sql="basedata" isSql="false" condition="1668" dataType="Long" listKey="bz" listValue="name" headerKey="" headerValue="請選擇" checkEmpty="true" checkDesc="更新週期" />
</td>
</tr>
附件上傳:(_add.jsp )
<tr>
<th width="150">附件:</th>
<td colspan="3">
<input name="attachFile" type="file" contenteditable="false" id="attachfile" size="40" checkEmpty="true" checkDesc="附件"> 附件最大不能超過20.00M
</td>
</tr>
//Action save()方法try添加相應代碼
String realpath = ServletActionContext.getServletContext().getRealPath(UPLOADPATH); zlaqJczlManager.saveJczl(zlaqJczl,realpath,getAttachFile(),getAttachFileFileName(),getAttachFileContentType());
ZlaqJczlManager.java添加附件相關方法
private static final String zl = "zlaq_jczl";
private ZlaqJczlDao zlaqJczlDao;
private AttachManager attachManager;
public void setAttachManager(AttachManager attachManager) {
this.attachManager = attachManager;
}
//附件上傳
public void saveJczl(ZlaqJczl zlaqJczl, String realpath, File attachFile,
String attachFileFileName, String attachFileContentType) {
zlaqJczlDao.save(zlaqJczl);
zlaqJczlDao.flush();
if(attachFile != null && attachFileFileName != null){
attachManager.saveAttach(realpath, zlaqJczl.getUserid(),zl, ""+zlaqJczl.getId(), attachFile, attachFileFileName, attachFileContentType);
}
}
//更新附件
public void updateJczl(ZlaqJczl zlaqJczl, String realpath, File attachFile,
String attachFileFileName, String attachFileContentType) {
zlaqJczlDao.update(zlaqJczl);
zlaqJczlDao.flush();
if(attachFile != null && attachFileFileName != null){
attachManager.delete(zl, ""+zlaqJczl.getId());
attachManager.saveAttach(realpath, zlaqJczl.getUserid(),zl, ""+zlaqJczl.getId(), attachFile, attachFileFileName, attachFileContentType);
}
}
//附件查看(Manager)
@Transactional(readOnly=true)
public ZlaqJczl getById(String id) {
ZlaqJczl dj = zlaqJczlDao.getById(id);
List<Attach> attach = attachManager.findByTableNameAndId(zl, ""+id);
dj.setAttach(attach);
return dj;
}
獲取當前員工姓名、編號、添加時間
//_list.jsp
<td align="left"><span title='${item.lx}'>${item.lx}</span></td>
//顯示優化
<td align="left"><c:if test="${item.gxzq == 30}">一個月</c:if>
<c:if test="${item.gxzq == 90}">一個季度</c:if>
<c:if test="${item.gxzq == 180}">半年</c:if>
<c:if test="${item.gxzq == 365}">一年</c:if>
</td>
<td align="left"><span title='${item.tjsjString}'><c:out value='${item.tjsjString}'/></span></td>
<td align="left"><span title='${item.ygbh}'>${item.ygbh}</span></td>
<td align="left"><span title='${item.ygxm}'>${item.ygxm}</span></td>
Action save()方法try添加相應代碼:
zlaqJczl.setYgbh(getLoginInfo().getUsername()); zlaqJczl.setYgxm(getLoginInfo().getRealname()); zlaqJczl.setTjsj(DateTools.getCurrentTime());
zlaqJczl.java添加相應set、get方法