SSH is not so mysterious. It can be built quickly in 10 minutes!

Source: Internet
Author: User

1: Create a database and create a table
2: Enable myeclipse and use myeclipse's database browsing to create a database connection. The connection target is the database created in step 1.
3: create a web project for the exam
4. Add struts support and delete the struts support library.
5: Add spring support (do not check the support library), open applicationcontext. XML, and delete allCodeReplace the following content:

Code

<? XML version = " 1.0 " Encoding = " UTF-8 " ?>
< Beans xmlns = " Http://www.springframework.org/schema/beans "
Xmlns: TX = " Http://www.springframework.org/schema/tx "
Xmlns: xsi = " Http://www.w3.org/2001/XMLSchema-instance "
Xsi: schemalocation = " Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
HTTP: // Www.springframework.org/schema/tx Http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
  " >

 

 

  < Bean ID = " Txmanager "   Class = " Org. springframework. Orm. hibernate3.hibernatetransactionmanager " Autowire = " Byname " />
  < TX: Annotation - Driven transaction - Manager = " Txmanager " />
</ Beans >

 

6: add the support for hibernate (do not check the support library). Select the name we created in step 2 for the database.
7: Open/WEB-INF/struts-config.xml, add a line of code behind <action-mappings/>

< Controller processorclass = " Org. springframework. Web. Struts. delegatingrequestprocessor " />

 

8: Open/WEB-INF/web. XML, add the following code (Note that if you are using the GBK encoding format, you can change the UTF-8 inside to GBK, other places do not need to change ):
 

Code

  < Context - Param >
< Param - Name > Contextconfiglocation </ Param - Name >
< Param - Value >
Classpath: applicationcontext. xml
</ Param - Value >
</ Context - Param >
< Listener >
< Listener - Class >
Org. springframework. Web. Context. contextloaderlistener
</ Listener - Class >
</ Listener >
< Filter >
< Filter - Name > Opensessioninviewfilter </ Filter - Name >
< Filter - Class >
Org. springframework. Orm. hibernate3.support. opensessioninviewfilter
</ Filter - Class >
< Init - Param >
< Param - Name > Singlesession </ Param - Name >
< Param - Value > True </ Param - Value >
</ Init - Param >
< Init - Param >
< Param - Name > Flashmode </ Param - Name >
< Param - Value > Commit </ Param - Value >
</ Init - Param >
</ Filter >
< Filter - Mapping >
< Filter - Name > Opensessioninviewfilter </ Filter - Name >
< URL - Pattern > /* </Url-pattern>
</Filter-mapping>
<Filter>
<Filter-Name> characterencodingfilter </filter-Name>
<Filter-class>
Org. springframework. Web. Filter. characterencodingfilter
</Filter-class>
<Init-param>
<Param-Name> encoding </param-Name>
<Param-value> UTF-8 </param-value>
</Init-param>
</Filter>
<Filter-mapping>
<Filter-Name> characterencodingfilter </filter-Name>
<URL-pattern>/* </url-pattern>
</Filter-mapping>

 

9: import the SSH package into the project or copy the JAR file to the/WEB-INF/lib directory, either.
10: Convert the database table to an object class (the column object class name is MoD). (If you do not know, you can do this: Open the myeclipse database browser window and open the connection created in step 2, go to the table directory under the DBO directory and right-click the created table and select hibernate reverse engining)
11. Create the DaO interface of the object class and include the following four methods:
Void add (mod );
Void del (integer ID );
Void Update (mod );
MOD get (integer ID );
List loadall ();
12: implement the DaO interface. This implementation class must inherit the hibernatedaosupport and register this class in the spring configuration file.
13: create and implement the business interface. Add a NOTE @ transactional (rollbackfor = {exception. Class}) to the class })
14: Create an action that inherits the dispatchaction and registers this class in spring.
15: Compile the page and modify the action
Test and complete!

 

 

Remember: set after DAO class and Biz class private
Dao:
Public class goodsdaoimpl extends hibernatedaosupport implements goodsdao {

 

Inherit the source code package of hibernatedaosupport:/Files/simcoder/ssh_framework.rar


Video tutorial: complete caseHttp://u.115.com/file/f61835a6ce
Ssh.exe

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.