[英]Struts2 action not working with result type both json and dispatcher
我有一个结果类型为json的Struts2动作。 该动作从Ajax调用,并且在客户端接收到响应(ArrayList)。 一切正常。 现在,如果发生任何登录错误,我需要将操作重定向到某个错误页面。 因此,我尝试包括另一种结果类型,以便可以调用JSP页面。 但是,它不起作用。 请帮忙。
我在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>
我的Java代码
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=[com.app.action.StockTransferOrderAction@19ae493, com.opensymphony.xwork2.DefaultTextProvider@1dedb45], property=struts]
11:38:49,574 DEBUG InstantiatingNullHandler:72 - Entering nullPropertyValue [target=[com.app.action.StockTransferOrderAction@19ae493, com.opensymphony.xwork2.DefaultTextProvider@1dedb45], property=org]
11:38:49,607 DEBUG InstantiatingNullHandler:72 - Entering nullPropertyValue [target=[com.app.action.StockTransferOrderAction@19ae493, com.opensymphony.xwork2.DefaultTextProvider@1dedb45], property=locale]
代替结果type =“ dispatcher”,请尝试type =“ redirect”,因为您只想重定向到loginerror页面
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.