Let me ask a question, maybe simple, but I am a newbie in Struts2.
I have this action method in ProfileAction action:
@Override
public String execute() throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
HttpSession session = request.getSession();
String id = (String) session.getAttribute("id");
if (id != null && !id.equals("") && !id.equals("0")) {
return SUCCESS;
}
return "noSession";
}
And this in the XML:
<action name="perfil" class="agenda.ProfileAction">
<result name="success" type="tiles">/profile.tiles</result>
<result name="noSession" type="tiles">/login.tiles</result>
</action>
<action name="conexion" class="agenda.ProfileAction" method="login">
<interceptor-ref name="jsonValidationWorkflowStack">
<param name="validation.excludeMethods">init,input</param>
</interceptor-ref>
<result name="loginSuccess" type="tiles">/login/success.tiles</result>
<result name="loginError" type="tiles">/login/error.tiles</result>
</action>
As you see, I have "noSession" result in default method, but when I run the page, it throws an exception because "input" result is required. When I replace "noSession" in the XML by "input", it works, but the side effect is that JSON validation does not work.
It seems that execute method is not being called. I have even place a throw exception and in fact, it is not called.
I am traying to call the action this way: