尝试使用
pass
参数重定向到外部 URL。
我的代码如下:
<action name="testit" class="TestAction" method="test">
<result name = "success" type = "chain">
<param name="location">${at.url}</param>
<param name="login">${at.login}</param>
<param name="pass">${at.pass}</param>
</result>
</action>
action类中的方法是:
public String test(){
at.setUrl("http://www.test.com");
at.setLogin("ssfd");
at.setPass("ssfd");
}
我面临以下错误:
Info: 2017-11-29 15:23:39 ERROR Dispatcher:38 - Exception occurred during processing request: null
java.lang.NullPointerException
at com.opensymphony.xwork2.util.OgnlTextParser.evaluate(OgnlTextParser.java:22)
at com.opensymphony.xwork2.util.TextParseUtil.translateVariables(TextParseUtil.java:170)
at com.opensymphony.xwork2.util.TextParseUtil.translateVariables(TextParseUtil.java:127)
at com.opensymphony.xwork2.util.TextParseUtil.translateVariables(TextParseUtil.java:49)
at com.opensymphony.xwork2.ActionChainResult.execute(ActionChainResult.java:207)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:371)
如何解决这个问题?
chain
结果类型不会重定向。而是使用 redirect
结果类型。
<action name="testit" class="TestAction" method="test">
<result name = "success" type = "redirect">
<param name="location">${at.url}</param>
<param name="login">${at.login}</param>
<param name="pass">${at.pass}</param>
</result>
</action>