2014-07-17 2 views
1

결과 유형이 json 인 Struts2 액션이 있습니다. 이 동작은 Ajax에서 호출되며 응답 (ArrayList)이 클라이언트 측에서 수신 중입니다. 이것은 잘 작동합니다. 이제 로그인 오류가 발생하면 작업을 오류 페이지로 리디렉션해야합니다. 그래서, JSP 페이지가 호출 될 수 있도록 하나 이상의 결과 유형을 포함하려고했습니다. 그러나 작동하지 않습니다. 도와주세요. 콘솔과 아무것도에 선 아래 얻기Struts2 액션이 json과 디스패처 모두 결과 유형으로 작동하지 않습니다.

Struts.xml 나의 행동

<action name="stocktransferorder" class="com.app.action.StockTransferOrderAction" 
      method="createSTO"> 
      <result name="jsonStockTransferOrderSuccess" type="json" /> 
      <result name="error" type="dispatcher">/jsp/loginError.jsp</result> 
     </action> 

내 자바 코드

String s = (String) session.getAttribute("SAPUSERID"); 
if (s != null && s.length() > 0) { 
     // My code goes here 
     return "jsonStockTransferOrderSuccess"; 

else 
     { 
      return "error"; 
     } 
} 

가 화면에 무슨 일이 일어나고

11:38:49,573 DEBUG ServletDispatcherResult:72 - Forwarding to location /jsp/loginError.jsp 
11:38:49,573 DEBUG InstantiatingNullHandler:72 - Entering nullPropertyValue [target=[[email protected], [email protected]], property=struts] 
11:38:49,574 DEBUG InstantiatingNullHandler:72 - Entering nullPropertyValue [target=[[email protected], [email protected]], property=org] 
11:38:49,607 DEBUG InstantiatingNullHandler:72 - Entering nullPropertyValue [target=[[email protected], [email protected]], property=locale] 
+0

이것은 ajax 요청입니다. 다른 페이지로 리디렉션하고 싶습니까? –

+0

결과 형식 JSON으로 AJAX 응답을 처리하고 있습니다. 그러나 오류가 발생하면 화면에 오류 메시지를 표시해야합니다. 일부 JSP 페이지로 리디렉션 할 수 있습니까? – minchi

+0

js? 물론 당신은 할 수. –

답변

0

result type = "dispatcher"대신 loginerror 페이지로 리디렉션하려는 경우 type = "redirect"시도

+0

여전히 동일합니다. 16 : 06 : 15,369 디버그 ServletRedirectResult : 72 - 16 /Matix/jsp/loginError.jsp finalLocation 리디렉션 : 06 : 15,370 DEBUG InstantiatingNullHandler : 72 - nullPropertyValue [목표 = [email protected] 입력 [email protected]], 속성 = 로캘] – minchi

관련 문제