struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Miten <>
Subject duplicate error messages
Date Thu, 10 May 2012 12:43:50 GMT

I am using struts 2.3.3 from maven.

I am using below code which produces messages for user and password twice.
one is default message showing up from not sure where as below.
username is required
password is required

while in my validate method on action I have messages as: 
username mandatory
password mandatory

I read few messages related to duplication and they suggest things like
singleton.  Well in my case I have basic example from maven tutorial
artifact and it has below files:
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
    <title>Sign On</title>

<s:form action="Login">
    <s:textfield key="username"/>
    <s:password key="password" />

 * $Id: 739661 2009-02-01 00:06:00Z davenewton $
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.

package tutorial.example;

public class Login extends ExampleSupport {

	public void validate() {
		// TODO Auto-generated method stub
		if (isInvalid(getUsername())) addFieldError("username", "username

        if (isInvalid(getPassword())) addFieldError("password", "password
    public String execute() throws Exception {

        if (isInvalid(getUsername())) return INPUT;

        if (isInvalid(getPassword())) return INPUT;

        return SUCCESS;

    private boolean isInvalid(String value) {
        return (value == null || value.length() == 0);

    private String username;

    public String getUsername() {
        return username;

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

    private String password;

    public String getPassword() {
        return password;

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


*struts.xml actually example.xml*
<?xml version="1.0" encoding="UTF-8" ?>
	&quot;-//Apache Software Foundation//DTD Struts Configuration 2.3//EN&quot;

  <package name="example" namespace="/example" extends="struts-default">
    <action name="HelloWorld" class="tutorial.example.HelloWorld">

    <action name="Login_*" method="{1}" class="tutorial.example.Login">
      <result name="input">/example/Login.jsp</result>
      <result type="redirectAction">Menu</result>

    <action name="*" class="tutorial.example.ExampleSupport">

and I invoke the action http://localhost:8080/tutorial/example/Login.action



View this message in context:
Sent from the Struts - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message