Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

where to write the code for intercepts

 
Aditi Gandy
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am new to Struts and wanted to know how to make example of Helloworld in Struts2 stateless and where to write the code for intercepts?

Can anyone please help me?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not clear to me what you're asking.
 
Stephanie Dutcheson
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You define interceptor in struts.xml
<interceptors>
<interceptor name="authentication" class="com.onepd.struts2.lesson.action.Authentication"/>
<interceptor-stack name="secureStack">
<interceptor-ref name="authentication"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>

implements Interceptor in say Authentication class, method intercept()
will do all job.

or set

<global-results>
<result name="error" type="redirectAction">
...
</result>
</global-results>

<global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="error"/>
</global-exception-mappings>

to process exceptions.

-----
Struts 2 tutorial
http://www.onepd.com
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic