Graphical MyEclipse configuration Struts+hibernate+spring+freemarker

Source: Internet
Author: User
Found on the Internet, for small o to share, this relatively intuitive point, to make a supplement. Oh

These days to hibernate and spring good look, and then think of some of the things struts, decided to integrate the 3 together, the performance layer with Struts+freemarker, business layer with spring,hibernate processing persistence layer. In struts, a delegate is used to delegate the processing of the action to spring, and struts is responsible for the page logic only.
A few days ago Eclipse 3.2+myeclipse5.0m2, feel myeclipse some things are good, use it to make an integration.
First, create a Web project:
  
  
Then, attach some of the struts files to the newly created project:
  
  
After completion the project structure is as follows:
  
Then add the hibernate required files:
  
  
  
  
  
  
After completion the project structure is:
  
Add the Spring file again:
  
Note the following selection:
  
  
  
When you are done, you will see:
  
Open that Applicationcontext.xml, will
  
To
  
Now still need to do some changes, in order to run without the error, I have written before Struts+hibernate, will throw a wrong, because hibernate contains the Xerces.jar, so now directly to delete it, no problem.
  
In spring and hibernate, there are 2 Log4j.jar, the old version is not good, so delete, change a new version.
Remove and, replace, then, add a log4j.properties under src:
  
The contents are as follows:
  
So the log4j is ready.
Next is to join freemarker,jsp, personal feeling.
First the next Freemarker.jar, add to the Web-inf under the Lib directory, and then, open Web.xml, add the following:
  
  
  
Here's a little combat drill.
Switch to MyEclipse's hibernate view.
  
To open a database connection:
  
  
Then, execute
  
  
Generate several files automatically:
  
Also, spring's applicationcontext.xml automatically joins
  
Then, set up the FTL page, according to the previous Web.xml configuration Freemarker settings, you need to establish the following directory
     
First the page logic, open Struts-config.xml, and then do the following operation
  
  
  
Continue to add
  
  
  
  
After the completion of the effect is as follows:
  
Here are 3 pages:
  
  
  
Note here the first 2 lines, with the Struts tab in the Freemarker.
I said the action was entrusted to spring, and it was promised to join in struts.
  
The action class then needs to modify the
  
The following setters are prepared for spring.
The action statement for struts configuration needs to be modified to show the agent:
  
Then add in spring's applicationcontext.xml:
  
Note that the name, not the ID, is used.
Publishing, running, and the result is a mistake.
  
Fortunately, the problem is not big, find add to the web-inf/lib under the can.
Start testing
  
Successful words:
  
Otherwise:
  
Then go to the database a look, depressed, data did not come in, tried N long, finally found spring to define a datasource. The original definition of sessionfactory changed to the following:
  
OK, everything's fine. Here, finished, just to explain how to use myeclipse for rapid development, after all, usually do the project to the progress, but also to supervise the quality, with MyEclipse, really convenient many.

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.