Summarize the integration Struts2+hibernate3+spring4 Development Java Web application process __java

Source: Internet
Author: User
Tags pack java web
- -------------------------------------------------------------------------------------------------------------- ------------------------------------------------ Development Examples: User Management System Implementation features: The system connects with the local database, supports the user's landing, registering, and querying the user's information on the Web page. Development Process: SSH Integration Development-user management system--0. Setting up the environment---the integration of a.spring and hibernate---the integration of b.spring and struts---c. Configuration of the configuration file--1. Implementation of the database---A . Table: Design of id,name,password,type--2.hibernate persistence layer---A. Writing the---of the Persistence Class B. Writing a mapping file--3.dao layer Design---A. Writing DAO layers Interface---B. Write the DAO layer interface implementation class--4. The design of the business logic layer---A. Writing service layer interface---B. To write the implementation class of the service layer interface---c. Configure the spring configuration file. Inject the DAO component--5 into the service's implementation class. Complete the design of user login--Presentation layer Struts2---A. Write the user login action class---B. To write a user logon login interface jsp file---c. Configure SP Ring configuration files and Web.xml and Struts.xml----------------------------------------------------------------------------------- ----------------------------------------------------------------------------- problems encountered in the development
Q1:spring and Hibernate consolidated when the Find method is invoked through This.getHibernateTemplate.find () in spring, the error user is not mapped [from user] resolves: Original error code: PublicList<user> FindAll () {String hql = ' from User '; return(list<user>) This. Gethibernatetemplate (). Find (HQL); The table name is user, and the reason for the syntax error of the user is not mapped [from user] appears: Hibernate is a query to the class, the original HQL statement "from user", the user is the datasheet, and the persisted class is user, so the HQL statement is changed to " From User to resolve the error. ----------------------------------------------------------------------------------------Q2: The property service in the Sturts layer action class is an object in the Serivce layer (the action class is injected through spring), but is found null when the action is instantiated to invoke the property service, and is not injected successfully. Solve: A. It is possible to configure an action in Struts.xml class value with the action name, without using the ID value of the Actionbean in spring as the class value (that is, not getting the action instance through the spring container, but instantiating the class name yourself); B. It is possible that the property <constant name= "Struts.objectfactory" value= "Spring" in the Struts.xml configuration file does not have a value set to spring------- ---------------------------------------------------------------------------------Q3: Error caused by:cannot locate the Chosen Objectfactory implementation:spring-[Unknown Location] Resolved: 1. Add Struts2-spring-plugin Jar Pack 2. Add the following configuration file XML

<!--Struts2 configuration--> <filter> <filter-name>struts2</filter-name> <filter-class> Org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter </filter-class> <init-param> <param-name>config</param-name> <param-value>Struts-default.xml,struts-plugin.xml, struts.xml</param-value> </init-param> </filter> <filter-mapping> <filter-name> Struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>

----------------------------------------------------------------------------------------q4:spring Integration Hibernate error, Workaround for the exception ' sessionfactory ' or ' hibernatetemplate ' is required: Step one: Add the following method in the Daoimp class that inherits the Hibernatedaosupport class, Use @autowired:Java Code@Autowired public void Setsessionfactoryoverride (Sessionfactory sessionfactory) {Super.setsessio       Nfactory (sessionfactory); Step two: In springAdd set Value injection when you configure a bean element for the Daoimp class in the configuration file. <property name= "sessionfactory" > <ref bean = "Sessionfactory"/> </property>--------- -------------------------------------------------------------------------------Q5: Error Java.lang.noclassdeffounderror:javax/transaction/transactionmanager solution: Google a bit, the original is less hibernate package in the Jta.jar. ----------------------------------------------------------------------------------------Q6: Error caused by: Java.lang.noclassdeffounderror:javax/persistence/entitylisteners Resolution: This is a hibernate3.6 version, so the JPA jar package is missing, and the jar package needs to be imported. Can be hibernate 3.6 distro:hibernate-distribution-3.6.0.final/lib/jpa/ Hibernate-jpa-2.0-api-1.0.0.final.jar found after the import will be OK. Serious in----------------------------------------------------------------------------------------q7:struts2: Dispatcher initialization failed Error resolution: Interceptor initialization failure, generally missing struts2-related jar pack




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.