一些常用配置文件

简介: applicationContext.xml com.tiantian.

applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
         http://www.springframework.org/schema/context
         http://www.springframework.org/schema/context/spring-context-3.0.xsd
         http://www.springframework.org/schema/tx
         http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
         http://www.springframework.org/schema/aop
         http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

	<context:annotation-config />
	<context:component-scan base-package="com.tiantian.tiantian" />

	<context:property-placeholder location="classpath:jdbc.properties" />

	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
		destroy-method="close">
		<property name="driverClassName" value="${jdbc.driverClassName}" />
		<property name="url" value="${jdbc.url}" />
		<property name="username" value="${jdbc.username}" />
		<property name="password" value="${jdbc.password}" />
	</bean>

	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="packagesToScan">
			<list>
				<value>com.tiantian.tiantian.model</value>
			</list>
		</property>

		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">
					org.hibernate.dialect.MySQLDialect
				</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.hbm2ddl.auto">update</prop>
			</props>
		</property>
	</bean>

	<bean id="transactionManager"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>

	<aop:config>
		<aop:pointcut id="productServiceMethods"
			expression="execution(* com.tiantian.tiantian..*.*(..))" />
		<aop:advisor advice-ref="txAdvice" pointcut-ref="productServiceMethods" />
	</aop:config>

	<tx:advice id="txAdvice" transaction-manager="transactionManager">
		<tx:attributes>
			<tx:method name="add*" propagation="REQUIRED" />
			<tx:method name="update*" propagation="REQUIRED" />
			<tx:method name="del*" propagation="REQUIRED"/>
			<tx:method name="*" propagation="SUPPORTS" read-only="true" />
		</tx:attributes>
	</tx:advice>

	<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>

</beans>

 

struts.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>

	<constant name="struts.devMode" value="false" />
	<constant name="struts.enable.SlashesInActionNames" value="true" />
	<constant name="struts.mapper.alwaysSelectFullNamespace"
		value="false" />

	<package name="default" namespace="/" extends="struts-default">
		<interceptors>
			<interceptor name="authentication" class="com.tiantian.tiantian.web.interceptor.AuthenticationInterceptor"></interceptor>
			<interceptor-stack name="myInterceptorStack">
				<interceptor-ref name="authentication"></interceptor-ref>
				<interceptor-ref name="defaultStack"></interceptor-ref>
			</interceptor-stack>
		</interceptors>
		<default-interceptor-ref name="myInterceptorStack"/>
				<default-action-ref name="mydefault"/>
		
		<global-results>
			<result name="forbidden">/WEB-INF/forbidden.jsp</result>
			<result name="Exception">/WEB-INF/error.jsp</result>
		</global-results>
		
		<global-exception-mappings>
			<exception-mapping result="Exception" exception="java.lang.Exception"></exception-mapping>
		</global-exception-mappings>
		
		<action name="mydefault">
			<result type="redirect">/</result>
		</action> <!-- 当输入的地址不存在的时候就转到主页 -->
		 
	</package>

	<!-- Add packages here -->

</struts>

 web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
	http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
	<welcome-file-list>
		<welcome-file>index.jsp</welcome-file>
	</welcome-file-list>
 
<!--	<error-page>-->
<!--		<error-code>404</error-code>-->
<!--		<location>/404.jsp</location>-->
<!--	</error-page>-->
<!--	<error-page>-->
<!--		<error-code>500</error-code>-->
<!--		<location>/500.jsp</location>-->
<!--	</error-page> -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/applicationContext*.xml</param-value>
	</context-param>

	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	<servlet>
		<servlet-name>dwr</servlet-name>
		<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
		<init-param>
			<param-name>crossDomainSessionSecurity</param-name>
			<param-value>false</param-value>
		</init-param>
	</servlet>
	<servlet-mapping>
		<servlet-name>dwr</servlet-name>
		<url-pattern>/dwr/*</url-pattern>
	</servlet-mapping>
	<filter>
		<filter-name>encodingFilter</filter-name>
		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>GBK</param-value>
		</init-param>
	</filter>

	<filter-mapping>
		<filter-name>encodingFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

	<filter>
		<filter-name>openSessionInView</filter-name>
		<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>openSessionInView</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

	
	<filter>
		<filter-name>servletFilter</filter-name>
		<filter-class>com.tiantian.tiantian.web.filter.ServletFilter</filter-class>
		<init-param>
			<param-name>targets</param-name>
			<param-value>LogoutServlet</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>servletFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	
	<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>
</web-app>

 

目录
相关文章
|
存储 NoSQL Redis
Redis配置文件解析
Redis配置文件解析
97 1
|
5月前
|
关系型数据库 MySQL Java
Dockerfile中常用配置项的功能都是什么?
Dockerfile是用于构建Docker镜像的文本文件,其指令执行基于文件所在目录。`FROM`指定了基础镜像,`RUN`执行命令,`CMD`定义默认启动命令,`ENTRYPOINT`配置启动容器的应用,`COPY`和`ADD`复制本地文件到镜像。`WORKDIR`设置容器内工作目录,`VOLUME`创建持久化数据卷,`EXPOSE`声明暴露端口,`ENV`设置环境变量,`LABEL`添加元数据,`USER`设定运行用户,`ARG`定义构建时环境变量,`ONBUILD`定义后续构建触发的操作,`STOPSIGNAL`设置停止信号,`HEALTHCHECK`定义健康检查。
常用配置
更改 File And Code Templates 选中 Includes 添加如下内容:
49 0
|
XML 数据库 数据格式
idea使用c3p0数据库连接池无法加载配置文件xml,配置文件放置的位置
idea使用c3p0数据库连接池无法加载配置文件xml,配置文件放置的位置
296 0
idea使用c3p0数据库连接池无法加载配置文件xml,配置文件放置的位置
|
开发工具
vim编辑器常用配置
vim编辑器常用配置
|
PHP 开发工具
PHPSTORM_常用配置_使用技巧
PHPSTORM_常用配置_使用技巧
|
存储
艾伟_转载:使用配置文件(.settings、.config)存储应用程序配置
引言 我不知大家早先是如何保存应用程序配置,以备下次打开时使用的,反正我开始学.Net的时候就去研究序列化,以二进制或XML格式的序列化来保存应用程序配置。这样每次都要建立单独的配置类,并书写读写配置代码,相当麻烦。
817 0
|
Java 应用服务中间件
tomcat配置文件详解
tomcat配置文件详解
1782 0