Javatpoint Logo
Javatpoint Logo

Struts 2 modelDriven interceptor example

The modelDriven interceptor makes other model object as the default object of valuestack.

Bydefault, action object is the default object of valuestack.

To use the modelDriven interceptor, you need to implement ModelDriven interface in your action class and override its method getModel().

It is found in the default stack bydefault. So you don't need to specify it explicitely.

Parameters of modelDriven interceptor

There is no parameter defined for modelDriven interceptor.

Example of modelDriven interceptor

Full example of modelDriven interceptor

Let's see the full example of modelDriven interceptor.

File: index.jsp
File: struts.xml
File: login-success.jsp
File: login-error.jsp


struts 2 modeldriven interceptor example output 1 struts 2 modeldriven interceptor example output 2

If you don't implement the ModelDriven interface, you need to use and user.password field names in index.jsp file otherwise given value will not be set.

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA