文件上传callback的问题
本帖最后由 wangyucan1321 于 2013-12-6 14:12 编辑1、JSP代码:
<script type="text/javascript">
function uploadFile(data){
alert(data.obj.id);
if(data.obj.id!=null){
alert(111);
upload();
}else{
frameElement.api.opener.reloadTable();
frameElement.api.close();
}
}
function close(){
frameElement.api.close();
}
</script>
<t:formvalid formid="formobj" dialog="true" usePlugin="password" layout="table" callback="@Override uploadFile" action="projectInfoController.do?save">
<table cellpadding="0" cellspacing="1" class="formtable">
<tr>
<td align="right"><label class="Validform_label">项目附件:</label></td>
<td colspan="3" class="value">
<div class="form" id="filediv"> </div>
<div class="form">
<t:upload name="files" id="projectUrl" extend="*.png;*.jpg;*.doc;*.docx;*.txt;*.ppt;*.xls;*.xlsx;*.html;*.htm;*.pdf;"buttonText="添加文件"uploader="projectInfoController.do?saveFiles" ></t:upload>
</div>
</td>
</tr>
</table>
</t:formvalid>
配置文件:
<value>projectInfoController.do?saveFiles</value>
save方法的代码:
@RequestMapping(params = "save")
@ResponseBody
public AjaxJson save(ProjectInfoEntity projectInfo, HttpServletRequest request ) {
AjaxJson j = new AjaxJson();
projectInfo.setOrgCode(ResourceUtil.getSessionUserName().getOrgCode());
projectInfo.setProjectUrl(request.getSession().getServletContext().getRealPath("upload"));
if (StringUtil.isNotEmpty(projectInfo.getId())) {
message = "更新成功";
ProjectInfoEntity t = projectInfoService.get(ProjectInfoEntity.class, projectInfo.getId());
try {
MyBeanUtils.copyBeanNotNull2Bean(projectInfo, t);
projectInfoService.saveOrUpdate(t);
systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
} catch (Exception e) {
e.printStackTrace();
}
} else {
message = "添加成功";
projectInfoService.save(projectInfo);
systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
}
j.setObj(projectInfo);
return j;
}
但是为什么Controller里面进不去savefiles方法呢?
被拦截了你改下spring-mvc.xml 下面有个例外Url配置的 把你的saveFiles的路径配上去 好了,请问如何限制上传文件的大小,还有,savefiles方法里面如何传参呢
页:
[1]