标签:
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方法
基础资料功能开发(附件上传、查看,获取当前用户信息、时间)
标签:
原文地址:http://www.cnblogs.com/Zhou7364/p/5827761.html