Preparatory work:
Java environment
Tomcat Environment (use tomcat8.0 here)
Eclipse (the Server runtime plugin has been added)
=================================================
1,eclipse New Dynamic Web Project (file-new-other-web), this article is named Sshtry
If target runtime is empty, you will need to first install several plugins via Eclipse-help-install new software to connect to the native tomcat (all Eclipse configuration Tomcat is configured)
2. Download struts Spring hibernate
http://struts.apache.org/
http://hibernate.org/orm/releases/
http://repo.springsource.org/release/org/springframework/spring/4.0.0.RELEASE/
3. Create a Struts project (you do not need spring hibernate at this time)
Copy the jar from the Struts plus package to: (No struts2-spring-plugin************ required, don't put it in)
Creating Web. XML under the Web-inf directory
<?xml version= "1.0" encoding= "UTF-8"? ><web-app id= "Webapp_9" 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/ Java http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd "><display-name>sshTry</display-name>< Filter><filter-name>ssh</filter-name><filter-class> org.apache.struts2.dispatcher.ng.filter.strutsprepareandexecutefilter</filter-class></filter>< filter-mapping><filter-name>ssh</filter-name><url-pattern>/*</url-pattern></ filter-mapping><welcome-file-list><welcome-file>register.jsp</welcome-file></ Welcome-file-list></web-app>
SRC directory under Create Struts.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> <include file=" Struts-default.xml "/> <package name= "Sshtry" extends= "Struts-default" > <action name= "register" class= " Com.fit.sshTry.action.RegisterAction "> <result name=" input ">/register.jsp</result> < Result name= "Success" >/succeed.jsp</result> <result name= "error" >/fail.jsp</result> </action> </package> </struts>
In the package tag, the name attribute is used as the definition of a packet name to differentiate the other person's code, and the extends property is used to inherit a parent package
The Name property in the action tag is used as the path to client access when the servlet ' s path
The class attribute in the action tag is used as the full path to the Aciton class corresponding to this action
The Name property in result within the action tag is the return value of the method corresponding to its parent tag, not the default is success
If the return value matches the value of the Name property, the path specified within the result tag is completed to jump
4 Writing Basic Classes
Is the basic Get Set method
Only registeraction special needs to write the Execute () method
5 Starting Tomcat
Address bar Write http://127.0.0.1:8080/register.jsp
register.jsp The action name in the Struts configuration file
Eclipse (Luna) build ssh (STRUTS2+SPRING4+HIBERNATE4)