Saturday, 15 August 2015

java - Customized Logging interceptor in Struts 2 with bean value -



java - Customized Logging interceptor in Struts 2 with bean value -

i writing customized interceptor audit logs purpose. want session attributes , request attributes in interceptor. example: i'll set username session , getting too. challenge is: defining 1 bean audit bean setting values bean

class="lang-java prettyprint-override">if (this.username.equals("admin")) { user.setusername(this.username); sessionattributes.put("user", user); auditbean.setperm("login success"); requestattributes.put("auditbean", auditbean); homecoming "success"; } else { auditbean.setperm("login failed initiaqlized"); requestattributes.put("auditbean", auditbean); addactionerror(gettext("error.login")); homecoming "error"; }

this request attribute requestaware obj. audit bean not able retrieve interceptor, please help regarding this.

class="lang-java prettyprint-override">map<string, object> sessionattributes = invocation.getinvocationcontext().getsession();

achieving session this.

class="lang-java prettyprint-override">map<string, object> requestattributes = invocation.getinvocationcontext().getparameters();

with above not able retrieve request params. it's showing jsp request params, not have set in action.

you can check invocation context in interceptor action context, straight context map.

map<string, object> requestattributes = (map<string, object>) invocation.getinvocationcontext().get("request");

or utilize alternate syntax

map requestattributes = (map) actioncontext.getcontext().get("request");

java struts2 customization interceptor actioncontext

No comments:

Post a Comment