Action Message tag in struts2

I am new to disposition on how to decorate action message and action errors on struts2 jsp page?

<s:actionmessage/> <s:actionerror/> 
+6
source share
3 answers

you can use css styles as well as jQuery theme attribute to decorate your action error and action message.

 <div class="error"><s:actionerror theme="jquery"/></div> <div class="message"><s:actionmessage theme="jquery"/></div> .message li { font-size: 14px; color: #000066; text-align: center; list-style: none; font-family: Trebuchet MS,sans-serif,inherit,Arial,monospace; } .error li { font-size: 14px; color: #990000; text-align: center; list-style: none; padding-right: 50px; } 
+4
source

Hi, I am posting a solution for your problem if you want your action messages and error messages to adorn the use of this code

 <div id="sucessMsg"><s:actionerror /></div> sucessMsg is the class that is using by struts2 internally so override this so kindly put the below code inside the css #sucessMsg { text-align: center; font-weight: bolder; color: #6A2A91; list-style: none; margin: auto; } #errorMsg { text-align: center; font-weight: bolder; color: red; list-style: none; width: 350px; margin: auto; } 
+2
source

You should look at the HTML source after rendering it to see the CSS classes and the HTML structure that Struts uses to render the message. You can also look in the template files.

By default, struts displays each action message as follows:

 <ul> <li><span class="actionMessage">${message}</span></li> </ul> 

Each message will have <li><span class="actionMessage">${message}</span></li> .

You can create CSS for actionMessage or change the template file for rendering as you want.

Template files for them are located in:

 /template/simple/actionerror.ftl /template/simple/actionmessage.ftl 

Field error can also be useful for you:

 /template/simple/fielderror.ftl 

Note: if you use the xhtml theme, these files can be located in this folder in the template

+1
source

Source: https://habr.com/ru/post/915084/


All Articles