s2sh framework for integration of

2010-03-29  来源:本站原创  分类:Java  人气:261 

struts2, spring and hibernate integration of the development. The integration of the three main spring of this is to use the middle frame, up to integrate struts2, downward integration of hibernate. The specific configuration is as follows.
struts-config.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>
        <!--  The default view topics  -->
    <constant name="struts.ui.theme" value="simple" />
    <constant name="struts.objectFactory" value="spring" />
    <constant name="struts.devMode" value="false" />
    <constant name="struts.convention.default.parent.package"   value="defaultpackage" />
     <constant name="struts.convention.package.locators" value="action" /> 

<package name="test"   extends="struts-default">
<action name="login">
        <result name="success">/success.jsp</result>
        <result name="error">/error.jsp</result>
</action>
</package>
</struts>

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 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/j2ee
        http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

        <!--  Specifies the spring configuration file, the default root directory from the web to find the configuration file, we can provide the classpath by spring  : Prefix from the class path in search  -->
        <context-param>
           <param-name>contextConfigLocation</param-name>
           <param-value>classpath:applicationContext.xml</param-value>
        </context-param>
        <!--  On the spring container instantiate  -->
        <listener>
              <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>

   <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>
         <filter>
             <filter-name>OpenSessionInViewFilter</filter-name>
             <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
     </filter>
    <filter-mapping>
             <filter-name>OpenSessionInViewFilter</filter-name>
             <url-pattern>/*</url-pattern>
     </filter-mapping>  

  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

LoginAction.java:

package action;
import java.util.List;

import entity.Usertable;
import service.LoginService;
public class LoginAction {

private LoginService loginService;
public LoginService getLoginService() {
        return loginService;
}
public void setLoginService(LoginService loginService) {
        this.loginService = loginService;
}
private String username;
private String password;
public String getUsername() {
        return username;
}
public void setUsername(String username) {
        this.username = username;
}
public String getPassword() {
        return password;
}
public void setPassword(String password) {
        this.password = password;
}
public Integer getAge() {
        return age;
}
public void setAge(Integer age) {
        this.age = age;
}
private Integer age;

public String execute()throws Exception{
        Integer i=2;
        Usertable u=loginService.findByid(i);
        /*List s=loginService.findByall();*/
        return "success";

}}

index.jsp:

<html>
  <head>
    <base href="<%=basePath%>">

    <title> Save user  </title>
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page">
        <!--
        <link rel="stylesheet" type="text/css" href="styles.css">
        -->
  </head>
  <body>
  <form action="login.action" method="post">
   <p> Please enter the following information:  </p>
    User name  :<input type="text" name="name">
   Password:  <input type="password" name="pass"><br>
   Your age  <input type="text" name="age">
  <input type="submit" name="a" value=" Submit  ">
  </form>
  </body>
</html>

Basically, less is the case, they have to add the appropriate service and serviceImpl. dao layer and the entity that can own under the reverse engineering. Integrating the results of the first look at the console does not Baocuo, then you can build their own databases, fill in the data test.

相关文章
  • s2sh framework for integration of 2010-03-29

    struts2, spring and hibernate integration of the development. The integration of the three main spring of this is to use the middle frame, up to integrate struts2, downward integration of hibernate. The specific configuration is as follows. struts-co

  • XFire Web Service framework for integration with Tomcat (1) 2010-12-30

    XFire Web Service framework for integration with Tomcat Liu Yan Although XFire is outdated, but the frustration with the previous projects the company is jdk1.4, so I can only choose the old chariot XFire Web Service development. First, we create a w

  • Framework for integration: is the server at startup time, load the appropriate framework for the configuration file 2010-03-18

    The integration of the framework : That is when the server was started, load the appropriate frame profile

  • Struts2.1.6 framework for integration with the Spring2.5.6 2008-07-16

    1, in the MyEclipse in the New Project (test) 2, Struts package into a temporary import the necessary packages, other packages will be used when the import: commons-fileupload-1.2.1.jar commons-logging-1.0.4.jar freemarker-2.3.13.jar ognl-2.6.11.jar

  • xser php framework successful integration of the powerful routing components Qee 2010-05-28

    See: http://qeephp.com/bbs/thread-11007-1-1.html Picture so:

  • MyEclipse s2sh framework package conflicts 2010-07-16

    xerces-2.6.2 cglib-nodep-2.1_3 Remove all published items under tomcat

  • Took two weeks to take a S2SH framework (throwing dead ah), hoping to help the novice like me 2010-07-26

    I bought this on behalf of the down-line test, debug, two weeks can finally run. Mainly to carelessness, and always Shen did not go, can not be that serious analysis of the code. I hope you learned a lesson. package com.user.action; import com.opensy

  • XFire Web Service framework for integration with Tomcat (2) 2010-12-30

    Wsdl as follows <? Xml version = "1.0" encoding = "UTF-8"?> <Wsdl: definitions targetNamespace = "http://webservice" xmlns: soapenc12 = "http://www.w3.org/2003/05/soap-encoding" xmlns: tns = "http://we

  • MyEclipse s2sh framework of packet collisions 2010-07-16

    xerces-2.6.2 cglib-nodep-2.1_3 In MyEclipse 6.5 hibernate and spring jar package under the conflict asm hibernate asm3.3.2 spring Remove the release of all the items tomcat

  • [Finally the text of the original one] S2SH with the EXT JS 3.1 Integration Project 2009-12-28

    Extjs before seeing the official Web site features a powerful and colorful interface, can not help but begin to learn, just beginning to learn do not really feel better, the exhaustion of the force feeding extjs finally combine the two demo as a Mess

  • SSH framework of the integration step 2010-11-08

    SSH framework of integration steps: 1. Built web project 2. Import struts2.0 the jar package (plus the five basic struts2-spring-plugin-2.0.14.jar) 3. Into the jar package spring, hibernate here, plus the associated package can be completed with myec

  • #翻译NO.1# --- Spring Integration Framework 2012-12-12

    Part II. Overview of Spring Integration Framework Spring Integration provides an extension of the Spring programming model to support the well-known Enterprise Integration Patterns. It enables lightweight messaging within Spring-based applications an

  • Graphical SSH framework configuration steps 2010-08-05

    Now developed a project using S2SH framework, configuration environment with a day or two, and now the environment was configured to write to the document issued under the order, are also considered to enhance point memory. A development environment

  • SSH framework of the configuration steps 2010-11-25

    Reprinted: http://haiyang08101.javaeye.com/blog/816272 Core Tip: It is now developing a project using S2SH framework, configure the environment with a day or two, and now the environment was configured to write to the document issued under the order,

  • Java Open Source AJAX Framework 2009-07-17

    Eclipse RAP Eclipse RAP project aims to enable developers to use Eclipse development model to build Rich, Ajax-enabled Web applications. The main use of the well-known Eclipse platform plug-in mechanism for expansion and a point contained in SWT / JF

  • Spring Study Notes: Spring Framework Overview 2010-03-29

    ◆ Introduction Objective: To solve the complexity of enterprise application development Function: Using the basic JavaBean to replace EJB, and provides additional functionality of enterprise applications Range: Any Java Application Spring Framework i

  • Spring Study Notes: Spring Framework Overview switch 2010-03-29

    http://www.javaeye.com/topic/583213 ◆ Introduction Objective: To solve the complexity of enterprise application development features: the use of basic JavaBean to replace EJB, and provides a more functional scope of enterprise applications: Any Java

  • SSH Integration Series 1 - Configuration Struts2.1.8.1, and test the first action 2008-10-29

    This article, first as a series of articles, will begin by explaining the following points: 1. System Platform: Struts: 2.1.8.1 Spring: Hibernate: tomcat: 5.5.27 MyEclipse: 7.5 2. This series of articles as the original article, if it appears in the

  • Testing framework to use Spring 2.5 TestContext 2008-09-19

    Spring 2.5 TestContext testing framework for testing Spring-based programs, TestContext testing framework and a low version of the Spring test framework does not in any way, is a new annotation-based testing framework for Spring recommend using the t

  • SSH Integration Series 1 2010-03-24

    This article, first as a series of articles, will begin by explaining the following points: 1. System Platform: Struts: 2.1.8.1 Spring: Hibernate: tomcat: 5.5.27 MyEclipse: 7.5 2. This series of articles as the original article, if it appears in the