|
|
|
Spring3 Getting Started 1 |
You need to know how simple J2EE web application structure is e.g. WEB-INF folder, context, web.xml before proceeding.
SpringWebMVC is MVC2 architecture as name suggests. So there will be a main Spring controller servlet,
your application server will need to know about this servlet i.e. entry is needed in web.xml.
Then Controller servlet will need to pass request and response to application web controllers.
Views shall have two state when it is loaded first time and second when user submits them.
Spring version used in this tutorial is: Spring-Version: 3.0.3. BTW version can be found in MANIFEST.MF file in
org.springframework.core-3.0.3.RELEASE.jar.
Steps
| 1 |
Create Web application folders and add Spring jars |
| 2 |
Change application web.xml for main Spring controller |
| 3 |
Add log4j files |
| 4 |
Create application-context.xml application controllers
|
| 5 |
Create command class or a value object (POJO) to pass your data |
| 6 |
Create Validator |
| 7 |
Create application Controller class
|
| 8 |
Create JSPs |
| 9 |
Run |
1A: Create web application folder structure
Note: Compiled classes shall go in classes folder
1B: Add following jars /WEB-INF/lib/
aopalliance.jar
aspectjrt.jar
aspectjweaver.jar
cglib-nodep-2.1_3.jar
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.4.jar
commons-lang-2.4.jar
commons-logging.jar
commons-net-1.1.0.jar
commons-pool.jar
commons-validator.jar
jstl.jar
log4j-1.2.15.jar
org.springframework.asm-3.0.3.RELEASE.jar
org.springframework.beans-3.0.3.RELEASE.jar
org.springframework.context-3.0.3.RELEASE.jar
org.springframework.core-3.0.3.RELEASE.jar
org.springframework.expression-3.0.3.RELEASE.jar
org.springframework.web-3.0.3.RELEASE.jar
org.springframework.web.servlet-3.0.3.RELEASE.jar
saxpath-1.0.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>SpringApp</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<context-param>
<description>spring context configuration</description>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/springapp-servlet.xml</param-value>
</context-param>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>springapp</param-value>
</context-param>
<context-param>
<description>
log4j configuration used by Log4jConfigListener
</description>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/classes/log4j.xml</param-value>
</context-param>
<context-param>
<description>
log4j configuration used by Log4jConfigListener
</description>
<param-name>log4jRefreshInterval</param-name>
<param-value>1000</param-value>
</context-param>
<listener>
<!-- Bootstrap listener for custom log4j initialization in a web environment -->
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener>
<listener>
<!-- Bootstrap listener to start up Spring's root WebApplicationContext. -->
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<display-name>springapp</display-name>
<servlet-name>springapp</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springapp</servlet-name>
<url-pattern>/login/form</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>springapp</servlet-name>
<url-pattern>/login/validate</url-pattern>
</servlet-mapping>
</web-app>
Note: org.springframework.web.servlet.DispatcherServlet is Spring controller servlet and
springapp-servlet.xml will contain application controller definitions.
See <url-pattern>/login/form</url-pattern>
and <url-pattern>/login/validate</url-pattern>
|
|
|
| How to loop arraylist JAVA6 Syntax
|
| How to iterrate through ArrayList and display multiple rows using for loop JAVA6 syntax..
|
| Java JSP |
2010-Oct-12 |
| How to loop arraylist
|
| How to iterrate through ArrayList and display multiple rows using for loop, JSTL tags..
|
| Java JSP |
2010-Oct-12 |
| Consumer using JAX WS Dispatch API and DOM parser 1
|
| Access/Consume Webservice using Servlet, JAX-WS Dispatch API dynamic client and parsing SOAP response using DOM parser...
|
| Java Webservice |
2010-Sep-20 |
| Simple Java first CXF Webservice 4
|
| Building Simple Java first CXF webservice using CXFServlet, Spring, jaxws:endpoint, @WebService, @SOAPBinding, @WebResult
|
| Java Webservice |
2010-Sep-19 |
| Simple Java first CXF Webservice 3
|
| Building Simple Java first CXF webservice using CXFServlet, Spring, jaxws:endpoint, @WebService, @SOAPBinding, @WebResult
|
| Java Webservice |
2010-Sep-18 |
| Simple Java first CXF Webservice 1
|
| Building Simple Java first CXF webservice using CXFServlet, Spring, jaxws:endpoint, @WebService, @SOAPBinding, @WebResult
|
| Java Webservice |
2010-Sep-18 |
| Simple Java first CXF Webservice 2
|
| Building Simple Java first CXF webservice using CXFServlet, Spring, jaxws:endpoint, @WebService, @SOAPBinding, @WebResult
|
| Java Webservice |
2010-Sep-18 |
| 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 |
| 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 |
|
|