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

  • Home
  • SEARCH
  • 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 8236287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:05:30+00:00 2026-06-07T19:05:30+00:00

I am using Struts2 – FileUploadInterceptor to handle content type and maximum size of

  • 0

I am using Struts2 – FileUploadInterceptor to handle content type and maximum size of the file being uploaded.

In order to display error messages, <s:fielderror/> is displaying error message which is perfect.

I am working on a page which has multiple sections and i need to display error messages belonging only to that section, problem with <s:fielderror/> is that it displays all error messages and to solve this parameters are to be passed, like

<s:fielderror><s:param>firstName</s:param></s:fielderror>

I am not sure what is the error key created by FileUploadInterceptor for content type error and maximum size error, please help me in addressing this issue.

  • 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-07T19:05:31+00:00Added an answer on June 7, 2026 at 7:05 pm

    If I understand you correctly, I think you want to do something like this:

    <s:fielderror>[some reference to a content type error]</s:fielderror>
    <s:fielderror>[some reference to a max size error]</s:fielderror>
    

    so that you can render them separately/differently.

    This is currently not possible since <s:fielderror/> only takes field names.
    You cannot separate the multiple errors for one field in this way.

    Additionally, looking at the source code for the acceptFile method in the FileUploadInterceptor, the max size is checked first and an error is set if that check fails. The code doesn’t continue to check for the allowed types if the max size already failed.

      353           } else if (maximumSize != null && maximumSize < file.length()) {
      354               String errMsg = getTextMessage(action, "struts.messages.error.file.too.large", new Object[]{inputName, filename, file.getName(), "" + file.length()}, locale);
      355               if (validation != null) {
      356                   validation.addFieldError(inputName, errMsg);
      357               }
      358   
      359               LOG.warn(errMsg);
      360           } else if ((!allowedTypesSet.isEmpty()) && (!containsItem(allowedTypesSet, contentType))) {
      361               String errMsg = getTextMessage(action, "struts.messages.error.content.type.not.allowed", new Object[]{inputName, filename, file.getName(), contentType}, locale);
      362               if (validation != null) {
      363                   validation.addFieldError(inputName, errMsg);
      364               }
      365   
      366               LOG.warn(errMsg);
      367           }
    

    So you should only get one of these errors at a time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got the following jsp page and I'm using struts2-jquery-plugin-3.1.1 <script type=text/javascript> function openDialog()
I am using struts2 in my application and trying to diplay error message using
I'm using Struts2, Spring, and Hibernate. I have written a simple Excel file called
I am attempting to update a page using Struts2 ( using jOWL to display
I want to componentization my project by using struts2 tiles plug-in. The tiles.xml file
I am using struts2, for that my struts.xml file contains code like : <?xml
I want to give file download using java,struts2 and ajax. On my html page
I am using Struts2,(jsp) to design page , I need three button on sing
I am using Struts2, Spring 2 and Junit 4.5. My main question is, whether
I am using struts2 to build a web application and I use struts2 tags

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.