`
ynp
  • 浏览: 442149 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

SSJ配置模板

阅读更多
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">
	<!-- web容器实例化spring实例 -->
	<context-param>
	  <param-name>contextConfigLocation</param-name>
	  <param-value>classpath:beans.xml</param-value>
	</context-param>
	<listener>
	  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	<!--OpenEntityManagerInView  -->
	<filter>
    	<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
        <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
	 </filter>
	 <filter-mapping>
	 	<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
	    <url-pattern>/*</url-pattern>
	 </filter-mapping>
	<!-- 处理中文字符乱码问题 -->
	<filter>
	<filter-name>encoding</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>encoding</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	<!-- 整合struts -->
	<servlet>
		<servlet-name>struts</servlet-name>
		<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
		<init-param>
			<param-name>config</param-name>
			<param-value>/WEB-INF/struts-config.xml</param-value>
		</init-param>
		<load-on-startup>0</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>struts</servlet-name>
		<url-pattern>*.do</url-pattern>
	</servlet-mapping>
	
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>


beans.xml(spring配置)----->
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"
		xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee"
		xmlns:tx="http://www.springframework.org/schema/tx"
		xsi:schemaLocation="
			http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
			http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
			http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
			http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
			http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
	   <!-- 配置entityManagerFactory 相当于(SessionFactory) -->
	   <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
	      <property name="persistenceUnitName" value="itcast"/>
	   </bean>
	  <!-- 配置事务信息 -->
      <bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
  	 	 <property name="entityManagerFactory" ref="entityManagerFactory"/>
      </bean>
	<!-- 采用注解方式进行事务配置 -->
 	<tx:annotation-driven transaction-manager="txManager"/>
	<!-- 采用注解注入对象 -->
	<context:annotation-config/>
		<bean id="personService" class="com.xx.service.impl.PersonServiceBean"></bean>
		<bean name="/list" class="com.xx.web.action.PersonAction"></bean>
</beans>


struts.cfg.xml----->
<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
          "http://struts.apache.org/dtds/struts-config_1_3.dtd">

<struts-config>
	<action-mappings>
		<action path="/list" type="com.xx.web.action.PersonAction" scope="request" validate="false">
			<forward name="list" path="/WEB-INF/page/list.jsp"/>
		</action>
	</action-mappings>
	<!-- 目的是让spring管理action bean-->
	<controller>
		 <set-property property="processorClass" value="org.springframework.web.struts.DelegatingRequestProcessor"/>
	</controller> 
	
</struts-config>



persistence.xml----->
<?xml version="1.0"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
  <persistence-unit name="itcast" transaction-type="RESOURCE_LOCAL">
      <properties>
         <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
         <property name="hibernate.connection.driver_class" value="org.gjt.mm.mysql.Driver"/>
         <property name="hibernate.connection.username" value="root"/>
         <property name="hibernate.connection.password" value="root"/>
         <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=UTF-8"/>
         <property name="hibernate.max_fetch_depth" value="3"/>
         <property name="hibernate.hbm2ddl.auto" value="update"/>
      </properties>
  </persistence-unit>
</persistence>
分享到:
评论

相关推荐

    SSJ.rar_Jap spring_ssj

    在"SSJ.rar_Jap_spring_ssj"这个项目中,开发者可能已经配置好了这三个组件的集成,使得它们能够协同工作。文件列表中只有一个"SSJ",这可能是项目的主入口点或者是配置文件的集合。在这个项目中,可能包含了以下...

    ssj9685.github.io

    在压缩包`ssj9685.github.io-master`中,我们可以期待找到项目的源代码、静态资源和配置文件。 JavaScript是一种广泛应用于Web开发的脚本语言,由Netscape公司的Brendan Eich在1995年发明。它是Web前端开发的核心...

    ssj_bk_basic:培训样本项目YII2 Bueng Kan省警察局23-24758

    通过这个项目,参与者将学习到如何使用YII2框架进行PHP开发,包括MVC的设计模式、路由配置、数据库交互、模板渲染、表单处理、认证和授权等核心概念。同时,他们也会了解如何利用Composer管理依赖,以及如何使用Git...

    spring-mvc-demo.zip

    8. **SSJ**:标签中提到的“ssj”可能是指Spring + SpringMVC + JPA(Java Persistence API),JPA是Java EE规范,用于对象关系映射。相比于MyBatis,JPA提供了更高层次的抽象,可以直接操作对象而不是SQL,简化了...

    北大青鸟SSM框架整合的超市订单购物系统

    6. **终身受用**:这个描述意味着该项目提供的SSM配置和实现是经过验证和优化的,可以作为一个基础模板,为其他类似的项目提供参考。无论是初学者还是有经验的开发者,都能从中学习到SSM框架的实用技巧和最佳实践。 ...

    java开发框架demo

    在"ssj"这个压缩包中,我们可以期待看到以下常见的项目目录和文件结构: 1. **src/main/java**:包含所有Java源代码,如Action类、Service层、DAO层等。 2. **src/main/resources**:可能存放配置文件,如Struts2的...

Global site tag (gtag.js) - Google Analytics