|
|
|
Get Started 1 |
You need to know how simple J2EE web application structure is e.g. WEB-INF folder, context, web.xml before proceeding.
Struts2 is MVC2 architecture framework. There will be one main Struts dispatcher filter,
your application server will need to know about this filter i.e. entry is needed in web.xml.
Then Filter will need to pass request and response to application web actions (struts.xml).
Views shall have two states when it is loaded first time and second when user submits them.
Struts2 version used in this tutorial is: Struts2-Version: struts2-core-2.1.6.
BTW version can be found in MANIFEST.MF file in Struts.jar: Bundle-Version: 2.1.6.
Steps
| 1 |
Create Web application folders and add Struts2 and common jars |
| 2 |
Change application web.xml for Struts2 filter StrutsPrepareFilter, StrutsExecuteFilter |
| 3 |
Create struts.xml for global application actions
|
| 4 |
Create login.xml for application action
|
| 5 |
Create log4j.xml for logging
|
| 6 |
Create DTO class or a value object (POJO) to pass your data |
| 7 |
Create application action class
|
| 8 |
Create application jsps
|
| 9 |
Run |
1A: Create web application folder structure
Note: Compiled classes shall go in classes folder
1B: Add following jars /WEB-INF/lib/
commons-beanutils-1.8.1.jar
commons-collections-3.2.1.jar
commons-dbcp.jar
commons-digester.jar
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
commons-io-1.4.jar
commons-lang-2.4.jar
commons-logging.jar
commons-net-1.1.0.jar
commons-pool.jar
commons-validator.jar
freemarker-2.3.13.jar
jstl.jar
junit-3.8.1.jar
log4j-1.2.15.jar
ognl-2.6.11.jar
spring-test-2.5.6.jar
struts2-core-2.1.6.jar
xwork-2.1.2.jar
2: /WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Struts2App</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts-prepare</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter
</filter-class>
</filter>
<filter>
<filter-name>struts-execute</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts-prepare</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts-execute</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
Note: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter is Struts filter and
struts.xml will contain application action definitions.
|
|
|
| Wheat Cookies
|
 Wheat cookies is a healthy snack for your fussy toddler......
|
| Babyfood |
2010-Aug-26 |
| Wheat Cookies
|
 Wheat cookies is a healthy snack for your fussy toddler......
|
| Veg Recipes Baking |
2010-Aug-26 |
| Encoding special characters in userinput or on server
|
| Encoding can be done either in Javascript or JAVA encodeURIComponent, escape, java.net.URLEncoder..
|
| Java JSP |
2010-Aug-09 |
| Jstl fmt tag i18n formatdate formatcurrency
|
| fmt:setBundle, native2ascii.exe, fmt:message, fmt:setLocale, fmt:formatDate, fmt:formatNumber type=currency..
|
| Java JSP |
2010-Aug-05 |
| How to read and write a file
|
| How to read and write a file java.io.BufferedReader,java.io.FileReader, InputStreamReader ...
|
| Java J2SE |
2010-Aug-04 |
| jQuery validate form using ajax 2
|
| How to validate/submit form using ajax and jQuery input#, ($.ajax)..
|
| Javascript |
2010-Jul-23 |
| jQuery validate form using ajax 1
|
| How to validate/submit form using ajax and jQuery ($.ajax)..
|
| Javascript |
2010-Jul-23 |
| Dosa
|
  Masala dosa is my favourite South Indian dish and I relish it it whenever we go to a South Indian food joint......
|
| Veg Recipes Parathas |
2010-Jul-14 |
| Palak Sukka/Spinach Sukka/Palakachi Sukhi Bhaji
|
 .JPG) If you are looking for a palak recipe apart from aloo palak or palak paneer, which quick yet delicious you are at the right place......
|
| Veg Recipes Dry Veg |
2010-Jul-13 |
| How to create datasource in RAD Websphere
|
| Create JDBC provider, datasource and JAAS security setup, JDBC connection URLs
|
| Servers Websphere |
2010-Jul-08 |
| Get Started 4
|
| Struts2 framework structure, how various components fit together
|
| Java Struts2 |
2010-Jul-07 |
| How to populate a form when JSP is called first time
|
| This is achieved throught setting bean in request, using frameworks like Struts2, Spring3..
|
| Java JSP |
2010-Jul-07 |
| Spring3 And Hibernate 4
|
| Spring3 and Hibernate 3.5.3 working together @Controller, @RequestMapping, @InitBinder, HibernateTransactionManager, LocalSessionFactoryBean, HibernateTemplate
|
| Java Spring |
2010-Jul-07 |
| Spring3 And Hibernate 3
|
| Spring3 and Hibernate 3.5.3 working together @Controller, @RequestMapping, @InitBinder, HibernateTransactionManager, LocalSessionFactoryBean, HibernateTemplate
|
| Java Spring |
2010-Jul-07 |
| Spring3 And Hibernate 1
|
| Spring3 and Hibernate 3.5.3 working together @Controller, @RequestMapping, @InitBinder, HibernateTransactionManager, LocalSessionFactoryBean, HibernateTemplate
|
| Java Spring |
2010-Jul-07 |
| Spring3 And Hibernate 2
|
| Spring3 and Hibernate 3.5.3 working together @Controller, @RequestMapping, @InitBinder, HibernateTransactionManager, LocalSessionFactoryBean, HibernateTemplate
|
| Java Spring |
2010-Jul-07 |
|
|