Change fielderror color?

jakarta-ee, java, jsp, struts2, validation

Solution

Struts2 adds `errorMessage` CSS class to error messages. You just need to add this to your CSS:

.errorMessage {
  color: red;
}

When you put `<s:head>` tag it added default styles to your page where `errorMessage` declaration looks like that:

.errorMessage {
  font-weight: bold;
  color: red;
}

Problem

I am using struts2 validation using the `validate()` method in my Action class. I add FieldErrors using `addFieldError()` method. The field error gets displayed on top of each field of my form. Action class: (This validates setMapServerDetails action) ``` /*---------------------VALIDATION------------------------------------*/ public void validateSetMapServerDetails(){ if(getMapServer().getServerName().length() == 0){ addFieldError("mapServer.serverName", "Name is Required"); } } ``` The problem is the error gets displayed in plain text, I want the error in red color. How should I change it to red? EDIT: JSP: ``` <title>Configure Map Server</title> <s:head /> </head> <body> <s:form action="setMapServerDetails" validate="true"> <s:textfield name="mapServer.serverName" label="Server Name"></s:textfield> <s:textfield name="mapServer.serverIp" label="Server IP"></s:textfield> <s:textfield name="mapServer.serverPort" label="Server Port"></s:textfield> <s:textfield name="mapServer.applicationName" label="Application Name"></s:textfield> <s:textfield name="mapServer.remarks" label="Remarks"></s:textfield> <s:submit value="Save"></s:submit> </s:form> ```

Original source