2012-05-07 4 views
6

struts2에 새로 추가 된 struts2 JSP 페이지에서 동작 메시지와 동작 오류를 장식 하시겠습니까? 이 메시지를 렌더링하는 경우에 사용하는 스트럿츠 CSS의 클래스와 HTML 구조를 볼 수 렌더링 후액션 메시지 태그 struts2

<s:actionmessage/> 
<s:actionerror/> 
+1

간단한 테마를 사용할 수 있으며 원하는 CSS 스타일을 적용 할 수 있습니다. –

답변

4

을 장식합니다.

<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; 
} 
1

당신은 HTML 소스를 볼 수 있습니다. 템플릿 파일을 볼 수도 있습니다. 다음과 같이 기본 스트럿으로

각 액션 메시지를 렌더링 :

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

모든 메시지가 <li><span class="actionMessage">${message}</span></li>있을 것이다.

actionMessage 용 CSS를 만들거나 원하는대로 렌더링 할 수 있도록 템플릿 파일을 변경할 수 있습니다. 뿐만 아니라 당신에게 유용 할 수 있습니다

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

필드 오류 :

이들에 대한 템플릿 파일

의 위치는

/template/simple/fielderror.ftl 

참고 :하면 해당 파일 XHTML의 테마를 사용하는 경우 템플릿 아래에 해당 폴더에 위치 할 수 있습니다

+0

모든 struts2 UI 태그에서 스타일 용도로 스타일, id 및 클래스 속성을 추가 할 수 있습니다. – Quaternion

2

안녕하세요. 문제에 대한 해결 방법은 당신은 당신의 액션 메시지와 오류 메시지는 당신이 당신의 작업 오류와 액션 메시지를 장식하는 CSS 스타일뿐만 아니라, JQuery와 테마 속성을 사용할 수 있습니다 사용이 코드

<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; 
}