Wednesday, 13 April 2016

How to make Struts 2 application ?


Make the directory structure

 1. Make source folder. Put following items :
     a. package with a class.
     b. struts.xml
     c. hello.xml
 2. Make jsp folder under webContent
    Put jsp file inside it.
 3. Put empty applicationcontext.xml under WEB-INF.
    Put web.xml under WEB-INF
 4. Make index.jsp in application root folder.


Add JARs in WEB-INF/lib folder

 antlr-2.7.2.jar
 commons-beanutils-1.6.jar
 commons-chain-1.1.jar
 commons-logging-1.0.4.jar
 commons-validator-1.3.0.jar
 freemarker-2.3.8.jar
 ognl-2.6.11.jar
 oro-2.0.8.jar
 struts-core-1.3.5.jar
 struts2-codebehind-plugin-2.0.6.jar
 struts2-config-browser-plugin-2.0.6.jar
 struts2-core-2.0.6.jar
 struts2-sitemash-plugin-2.0.6.jar
 struts2-spring-plugin-2.0.6.jar
 struts2-struts1-plugin-2.0.6.jar
 xwork-2.0.1.jar
 spring.jar
 commons-digester-1.6.jar
 commons-collections-3.1.jar


Give entries in web.xml  
for filter and filter-mapping (struts2), Spring listener, faces listener. 


Code struts.xml (keep it in classpath)
Give the entry of xml file you want to use as struts configuration, include that file (like: hello.xml) using include tag.


Make struts configuration XML
Give DTD, package name, namespace name, action definition having class name and action name.


Code the applicationContext.xml
Spring configuration


Code the action class


Write the JSP file 
/Webroot/jsp/HelloWorld.jsp

No comments:

Post a Comment

Note: only a member of this blog may post a comment.