You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Lukasz Lenart (JIRA)" <ji...@apache.org> on 2017/04/13 05:38:41 UTC
[jira] [Closed] (WW-4782) Struts2.5.10.1 upload photo file can't
set success
[ https://issues.apache.org/jira/browse/WW-4782?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Lukasz Lenart closed WW-4782.
-----------------------------
Resolution: Not A Problem
You have messed up configuration, see logs and you will notice that the action used is {{ActionSupport}} and not your action. Also you should use action name not url when defining the form's {{action}} attribute, so instead of {{<s:form action="appUploadHeadPhotoAction.do"}} it should be {{<s:form action="appUploadHeadPhotoAction"}} (assuming you have used such a name in struts.xml).
Please ask question as such on the User mailing list http://struts.apache.org/mail.html
> Struts2.5.10.1 upload photo file can't set success
> --------------------------------------------------
>
> Key: WW-4782
> URL: https://issues.apache.org/jira/browse/WW-4782
> Project: Struts 2
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.5.10
> Environment: Windows10 ,jdk1.7.80, struts2.5.10.1
> Reporter: fairy
> Labels: struts2.5.10.1, upload
>
> Hi ,today i found my application can't upload file success,Could you help me check it?
> I have do it follow the guide:
> http://struts.apache.org/docs/file-upload.html
> the error message as below :
> {noformat}
> Unexpected Exception caught setting 'upload' on 'class com.opensymphony.xwork2.ActionSupport: Error setting expression 'upload' with value ['org.apache.struts2.dispatcher.multipart.StrutsUploadedFile@22261709', ]
> ERROR ParametersInterceptor Developer Notification (set struts.devMode to false to disable this message):
> Unexpected Exception caught setting 'uploadContentType' on 'class com.opensymphony.xwork2.ActionSupport: Error setting expression 'uploadContentType' with value ['image/jpeg', ]
> ERROR ParametersInterceptor Developer Notification (set struts.devMode to false to disable this message):
> Unexpected Exception caught setting 'uploadFileName' on 'class com.opensymphony.xwork2.ActionSupport: Error setting expression 'uploadFileName' with value ['tabletennis_head.jpg', ]
> {noformat}
> index.jsp
> {code:xml}
> <div class="row">
> <div class="col-md-12">
> <s:actionerror cssClass="alert alert-error" />
> <s:fielderror cssClass="alert alert-error" />
> <s:form action="appUploadHeadPhotoAction.do"
> method="POST" enctype="multipart/form-data">
> <s:file name="upload" label="File" />
> <s:submit cssClass="btn btn-primary" />
> </s:form>
> </div>
> </div>
> {code}
> Action file:
> {code:java}
> private File upload;
> private String uploadContentType;
> private String uploadFilename;
> public File getUpload() {
> return upload;
> }
> public void setUpload(File upload) {
> this.upload = upload;
> }
> public String getUploadContentType() {
> return uploadContentType;
> }
> public void setUploadContentType(String uploadContentType) {
> this.uploadContentType = uploadContentType;
> }
> public String getUploadFilename() {
> return uploadFilename;
> }
> public void setUploadFilename(String uploadFilename) {
> this.uploadFilename = uploadFilename;
> }
> public String execute() {
> System.out.println("--------haaaaaaaaaa-----start---------------");
> System.out.println(upload);
> System.out.println(uploadContentType);
> System.out.println(uploadFilename);
> System.out.println("--------haaaaaaaaaa------end--------------");
> return SUCCESS;
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)