struts2上传图片并显示出来
struts2上传图片并显示出来,跪求指点,憋一下午了。怎么办,哪里错了
Action 里代码
public String doUpload() throws
IOException{
//获取图片路径
String savePath = ServletActionContext.getServletContext().getRealPath("/upload/"+this.uploadFileName);
FileInputStream fis = new FileInputStream(upload);
FileOutputStream fos = new FileOutputStream(savePath);
IOUtils.copy(fis, fos);
fos.flush();
fos.close();
fis.close();
return SUCCESS;
}
Struts.xml配置
<package name="default" extends="struts-default">
<action name="UploadAction" class="com.dbccv.wxEService.xm.personalcenter.action.UploadAction" >
<!-- 限制图片的格式和图片的大小 -->
<interceptor-ref name="fileUpload">
<param name="allowedTypes">
image/bmp,image/png,image/gif,image/jpeg,image/jpg
</param>
<param name="maximumSize">102400</param>
</interceptor-ref>
<!-- 默认的拦截器,必须要写 -->
<interceptor-ref name="defaultStack" />
<result name="success">/personaldate/ajax.jsp</result>
<result name="refresh">/personaldate/index.jsp</result>
</action>
</package>
显示界面
<body>
<s:iterator value="uploadFileName" var="filename">
<img alt="照片" src="upload/<s:property value='filename'/>" width="100" height="100" onmouseover="check()" id="img"/>
</s:iterator>
</body>
报错浏览器显示
后台报错
------解决方案----------