Multiple Namespace:-
We can define multiple namespaces in struts.xml file by the namespace attribute of package element. As we know, default namespace is /(root).
Let's see the simple example to define multiple namespaces in struts.xml file.
execAndWait interceptor:-
1- The execAndWait interceptor also known as execute and wait interceptor is used to display the intermediate result.
2- It is recommended to use for long running action.
3- It is not found in the default stack bydefault. So you need to specify it explicitely.
4- If you don't specify "wait" result, struts framework displays an intermediate result until your request is completed.
5- For the custom intermediate result, you need to define "wait" result in struts.xml file. In your page, you can display processing image
etc. So, it is better to specify the custom result.as below:-
Interface ServletRequestAware:-
All Actions that want to have access to the servlet request object must implement this interface.
This interface is only relevant if the
Action is used in a servlet environment.
Note that using this interface makes the Action tied to a servlet environment, so it should be<> avoided if possible since things like unit testing will become more difficult.
FileUpload Example:-
1- Create imageUpload.jspwhere you have to upload images/file.
Snapshot of piece of code is given below:-
2-create struts.xml as snapshot is given below:-
3-create action class FileUpload.Struts2_Sample_Using_FileUpload_Interceptor as snapshot given:-
4- Create displayImage.jsp on success event occurs:-
As snapshot given below:
0 comments:
Post a Comment