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 6718345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:57:29+00:00 2026-05-26T08:57:29+00:00

I am using the struts2 validation framework to validate the data from in client.

  • 0

I am using the struts2 validation framework to validate the data from in client.
I have read a lot of validation framework tutorials but still cannot not find where i make the mistake.

I use Struts 2.2.3. The struts.xml configuration as following:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
    "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
  <constant name="struts.devMode" value="true" />

  <package name="admin" namespace="/" extends="struts-default">
    <default-action-ref name="index" />

    <global-results>
      <result name="error">/error.jsp</result>
    </global-results>

    <global-exception-mappings>
      <exception-mapping exception="java.lang.Exception" result="error" />
    </global-exception-mappings>

    <action name="login" class="com.text.LoginAction">
      <result name="login">/login_page.jsp</result>
      <result name="success">/login_success.jsp</result>
      <result name="error">/login_page.jsp</result>
    </action>
  </package>
</struts>

In the index.jsp, i go struts2 action and enter login page.

<body>
  <a href="login!handle.action">Go to Login Page</a>
</body>

login_page.jsp

<body>
  <s:form action="login!login.action" validate="true" method="post">
    <s:textfield name="username" label="Username"/>
    <s:textfield name="password" label="Password"/>
    <s:submit value="Submit"/>
  </s:form>
</body>

LoginAction, @SkipValidation annotation is used to skip the validation for specific method

public class LoginAction extends ActionSupport {

    private static final long serialVersionUID = 1L;

    private String username;
    private String password;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String login() {
        if (username.equalsIgnoreCase("root") && password.equalsIgnoreCase("1234")) {
            return "success";
        } else {
            return "fail";
        }
    }

    @SkipValidation
    public String handle() {
        return "login";
    }
}

LoginAction-validation.xml in the same package with LoginAction.

<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
     "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">

<validators>
  <field name="username">  
    <field-validator type="requiredstring">
      <param name="trim">true</param>
      <message>Login name is required</message>  
    </field-validator>
  </field>

  <field name="password">
    <field-validator type="requiredstring">
      <param name="trim">true</param>
      <message>Password is required</message>
    </field-validator>
  </field>  
</validators>

After adding the validate=”true” in s:form, i go to the page and try to access validation.js and utils.js. They turn out to be the apache tomcat error report file. I think it means the client side validation doesn’t work. Can anyone help me to fix it? Thank you in advance.

  • 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-05-26T08:57:30+00:00Added an answer on May 26, 2026 at 8:57 am

    By mapping to .action, instead of the wildcard as documented in the S2 web.xml docs you prevent S2 from serving the required JavaScript files.

    You may extract the static files S2 normally serves itself, or correct your mapping.

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

Sidebar

Related Questions

I have this code for login validation using a Struts2 action class which calls
i am validating user input in my application using Struts2 build in validation framework
I needed to create an application using Struts2 as MVC,Hibernate for data access and
I am new to struts2, prior to this I have been using struts1.2, Spring
I have a j2ee web application running on struts. I am using validation XMLs
I am using struts2 (2.1.6) and want to redirect to Action2 from Action1 .
I'm Using Struts2 in jsp page i have iterator values for checkbox. how to
we are using Struts2 in our code and I have scenario where I need
The struts2 validation framework allows you to define your validation for an action or
I am using Struts2 with jsp pages and xwork validation. My problem is in

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.