I have to use some listener class to listen all pages. According to the url, I must split it and get some informations.
For example :
x.domain.com/$member
I want to get the member name through url, get the following bean and retrieve some database informations.
So, I created a PhaseListener to do the job, but it is not called every times I needed it, for example in case of 404 error.
How can I proceed ?
Thanks a lot :)
PS : I am using Glassfish 4.1.
Use a servlet filter which is mapped on both normal and error page requests:
<filter-mapping>
<filter-name>yourFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
그런 다음 필터 내에서 RequestDispatcher#ERROR_REQUEST_URI
오류 페이지에서 트리거되었는지 여부를 입력 한 요청 속성의 존재 여부를 확인할 수 있습니다 .
String errorRequestURI = (String) request.getAttribute(RequestDispatcher.ERROR_REQUEST_URI);
if (errorRequestURI != null) {
// Error page was triggered on the given URI.
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다