Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8324843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:13:28+00:00 2026-06-09T00:13:28+00:00

When I try upload file in struts2 I get in my view a validation

  • 0

When I try upload file in struts2 I get in my view a validation error: Invalid field value for field “upload”.
And in JBoss console I get:

10:37:56,140 WARN  [OgnlValueStack] Error setting expression 'upload' with value '[Ljava.lang.String;@17c7b19'
ognl.MethodFailedException: Method "setUpload" failed for object bm.action.content.SaveNewBannerAction@13ebb53 [java.lang.NoSuchMethodException: bm.action.content.SaveNewBannerAction.setUpload([Ljava.lang.String;)]
    at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1289)
    at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1478)
    at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85)
    at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162)
...
...
Caused by: java.lang.NoSuchMethodException: bm.action.content.SaveNewBannerAction.setUpload([Ljava.lang.String;)
    at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1230)

/-- Encapsulated exception ------------\
java.lang.NoSuchMethodException: bm.action.content.SaveNewBannerAction.setUpload([Ljava.lang.String;)
    at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1230)
    at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1478)
    at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85)
    at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162)

My jsp:

<div class="v4DDfiltering">
    <s:fielderror/>
    <s:form id="saveNewBannerForm" name="saveNewBannerForm"
        action="SaveNewBannerAction" theme="simple" method="POST" enctype="multipart/form-data">
...
        <div class="OneFilteringRow">
            <s:label for="upload" value="Plik:*" />
            <s:file id="upload" name="upload"/>
        </div>
...
        <div class="OneFilteringRow">
            <s:url id="saveNewBannerUrl" action="SaveNewBannerAction" />

            <sj:a href="%{saveNewBannerUrl}" targets="messagesDiv"
                formIds="saveNewBannerForm">
                Save
            </sj:a>

        </div>
    </s:form>
</div>

My action class SaveNewBannerAction.java

public class SaveNewBannerAction extends BaseAction {
    private static final long serialVersionUID = 1L;

    private static final Log LOG = LogFactory.getLog(SaveNewBannerAction.class);

    private boolean validate = true;

    private File upload;// The actual file
    private String uploadContentType; // The content type of the file
    private String uploadFileName; // The uploaded file name
    private String fileCaption;// The caption of the file entered by user
        ...

    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 getFileCaption() {
        return fileCaption;
    }

    public void setFileCaption(String fileCaption) {
        this.fileCaption = fileCaption;
    }
    @Override
    public void validate() {
        LOG.info("Enter: validate()");

        LOG.info("VALIDATE FIELDS");
        ...
        if(upload == null) {
            addFieldError("upload",
                    "Proszę uzupełnić pole: plik.");
            validate = false;
        } else {
            if(!uploadContentType.contains("image")) {
                addFieldError("upload",
                        "Wprowadzono niepoprawny format pliku. Plik musi być obrazkiem.");
                validate = false;
            }
        }

        LOG.info("Exit: validate()");
    }

I will be grateful for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:13:30+00:00Added an answer on June 9, 2026 at 12:13 am

    Your jsp should like this:

    <div class="v4DDfiltering">
        <s:fielderror/>
        <s:form id="saveNewBannerForm" name="saveNewBannerForm"
            action="SaveNewBannerAction" theme="simple" method="POST" enctype="multipart/form-data">
    ...
            <div class="OneFilteringRow">
                <s:label for="upload" value="Plik:*" />
                <s:file id="upload" name="upload"/>
            </div>
    ...
            <div class="OneFilteringRow">
                <sj:submit targets="messagesDiv"/>
            </div>
        </s:form>
    </div>
    

    OR:

    <div class="v4DDfiltering">
        <s:fielderror/>
        <s:form id="saveNewBannerForm" name="saveNewBannerForm"
            action="SaveNewBannerAction" theme="simple" method="POST" enctype="multipart/form-data">
    ...
            <div class="OneFilteringRow">
                <s:label for="upload" value="Plik:*" />
                <s:file id="upload" name="upload"/>
            </div>
    ...
        </s:form>
        <sj:a targets="messagesDiv" formIds="saveNewBannerForm">Save</sj:a>
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this error when I try to upload a file of 3,424KB and
I get this error when i try to upload an image: OSError at /upload/
Whenever I try to upload a file to a server the current View is
I try this command to upload a file (standard.xml) into table book the file
im trying to do a file upload using http post but when I try
I have the following script below where I try to mimic a file upload
HI I Try Upload a file in Silver-Light. for doing this I use System.IO.File
When I try to upload a file on my localhost version of the website
hi i got list of warning regarding file size when i try to upload
I'm using Kohana3 framework and Uploadify plugin for ajax file upload. When I try

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.