S2sh: struts2 + spring + hibernate. The three frameworks are integrated.
First, add the struts2 framework for the project:
1. First, you need to use ide to create a web project. myeclipse6.5 is used.
2. Introduce the struts2 jar package.
Most of the files found on the Internet are the introduction of 5 core jar package: commons-logging-1.0.4.jar, freemarker-2.3.13.jar, ognl-2.6.11.jar, struts2-core-2.1.6.jar, xwork-2.1.2.jar
However, when the struts2 framework is set up, an exception is thrown when the service system is started:
Unable to load configuration. - bean - jar:file:/D:/Program%20Files/Apache%20Software%20Foundation/Tomcat%206.0/webapps/s2shFrame/WEB-INF/lib/struts2-core-2.1.6.jar!/struts-default.xml:46:178
If this exception is thrown, You need to introduce two jar packages in the commons-fileupload-1.2.1.jar, commons-io-1.3.2.jar
3. After importing the jar package, you must configure struts information in Web. xml.
<filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class></filter><filter-mapping><filter-name>struts2</filter-name><url-pattern>/*</url-pattern></filter-mapping>
4. Add struts. xml under the src directory of the project and write data to the XML file.
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"><struts></struts>
5. So far, the construction of a struts2 framework is complete.
Now, in a simple test using the struts2 framework
First, modify the index. jsp page.
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
Pay attention to some usage in form labels.
Configure sturts. xml
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"><struts><package name="struts2" extends="struts-default"><action name="struts2Test" class="sturts2.test.testAction" method="test"><result name="success" type="redirect">index1.jsp</result></action></package></struts>
Create the testaction class and add the test method
package sturts2.test;import com.opensymphony.xwork2.ActionSupport;public class testAction extends ActionSupport{public String test(){return SUCCESS;}}
Added the returned JSP page index1.jsp.
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
Now we can test it. Start the Tomcat service and type the http: // localhost: 8080/s2shframe/index. jsp address.