FormFile类型如何转换为String

xuexixx xuexixx 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
uploadFfile.jsp

<……>
<html:form action="/uploadTest" enctype="multipart/form-data">
图片上传 : <html:file property="enterprise.logo" />
<html:submit />
<html:cancel />
</html:form>
<……>
================================
struts-config.xml

<……>
<struts-config>
<data-sources />
<form-beans >
<form-bean name="uploadForm" type="com.test.forms.UploadForm" />
</form-beans>

<global-exceptions />
<global-forwards />
<action-mappings >
<action
name="uploadForm"
path="/uploadTest"
input="/uploadFfile.jsp"
scope="request"
type="com.test.actions.UploadAction" />

</action-mappings>
<……>
</struts-config>
====================================
UploadForm

<……>
public class UploadForm extends ActionForm {
private Enterprise enterprise = new Enterprise();

public void setEnterprise(Enterprise enterprise){
this.enterprise = enterprise;
}

public Enterprise getEnterprise(){
return enterprise;
}
}
<……>

==========================
下边是EnterpriseDto

public class EnterpriseDto{
private String logo; //logo地址
public void setLogo(String logo){
this.logo= logo;
}

public String getLogo(){
return logo;
}
}

=======================================
UploadAction

public class UploadAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
UploadForm uploadForm = (UploadForm )form;
FormFile logo = uploadForm.getEnterprise().getLogo();//在报的错是不能从String转化为FormFile

//我要在这得到Enterprise中的String logo保存在数据库中该如何写??急急急
}
}
...全文
评论 7
收藏 已收藏
分享
返回顶部
xuexixx
Web 开发 81,108 成员 341,721 内容