• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 parameters is coming null in action class when using Interceptors

 
Santhosh Kalisamy
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

When I am using Interceptors, the values on Action class coming as null. I have removed the Interceptors, the values coming perfect from the JSP page.

Login.jsp



LoginAction.java

web.xml


struts.xml (working version)



struts.xml (Notworking version )


AuthenticationInterceptor.java


Logs statements (both cases)



Any suggestions?
 
Santhosh Kalisamy
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fixed this issue by including default Interceptors.



struts.xml


Hope this helps, you all.
 
Alessandro Gentile
Greenhorn
Posts: 12
Eclipse IDE Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With Struts 2.3.15 still the same issue.
Your workaround works fine. Thanks Santhosh!!!
 
Joe Ess
Bartender
Pie
Posts: 9266
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alessandro Gentile wrote:With Struts 2.3.15 still the same issue.


This is not an "issue". This is how Struts works. The ParametersInterceptor places the request parameters on the Value Stack and the ActionMappingParametersInterceptor sets the values on the Action. If you do not have these interceptors in your stack, the values in your action will be null.
It is a good idea to read the Interceptor documentation before changing interceptor stack or you can have other side effects as well.
 
Alessandro Gentile
Greenhorn
Posts: 12
Eclipse IDE Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Joe, I've just made a fool of myself!!
I was misled by the previous post where this whole matter is presented as an "issue".
I confess my utter ignorance. Struts2 has a steep learning curve, there's a lot to read!
Thanks for your advice!!!
 
Joe Ess
Bartender
Pie
Posts: 9266
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No worries. Once you get the hang of it, it is pretty slick how you can drop in Interceptors to modify how Struts works, but yea, just starting out it's pretty strange.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic