What’s Motion class in Struts
Mannequin – Motion courses
View – Motion kind courses
Controller – Motion Servlet courses
What’s Motion Class in Struts ?
For instance, Motion class can create a library object add books to that library object, it could actually retailer chosen books by a selected reader to the session.
In short, we will describe Motion as:
Ø Our Motion class is prolonged by “org.apache.struts.motion.Motion class”.
Ø We have to override execute() methodology of Motion class.
Ø Motion servlet choose Motion class for incoming HTTP Request outlined beneath the motion mapping tag in struts-config.xml file
Ø Motion class is used to invoke enterprise or knowledge entry logic get knowledge from bean and retailer processed knowledge to bean and return end result or errors relying on the state of affairs,
Ø Motion courses are multi-threaded so we have to fastidiously deal with the motion variable as they don’t seem to be thread-safe when working with the multi-threaded atmosphere.
How you can Use Motion Class
In easy steps, we are going to see how you can use Motion class.
1. First prolong the org.apache.struts.motion.Motion class.
2. Override the next methodology
public ActionForward execute(ActionMapping mapping,
ActionForm kind,
HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException
Right here we develop our enterprise logic and put together the response to return the shopper.
3.Then we configure this motion to struts config file of our software inside motion mapping :
<action-mappings>
<motion
path=”/TestAction”
sort=”Instance.TestAction”>
<ahead identify=”success” path=”/ExamplePages/TestAction.jsp”/>
</motion>
</action-mappings>
That is all concerning the motion class in subsequent article will take care of completely different sort of motion class supplied by struts framework.
Different Java article from Java67 Weblog