几种常用的xml配置,Spring,Struts,Mybatis,sitemesh

Spring Application Context

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
	<!-- mybatis configuration -->
	<bean id="datasource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
		<property name="driverClassName" value="com.MysqL.jdbc.Driver"></property>
		<property name="url" value="jdbc:MysqL://localhost:3306/test"></property>
		<property name="username" value="root"></property>
		<property name="password" value=""></property>
	</bean>
	
	<!-- sql session factory -->
	<bean id="sqlSessionFactory" class="org.mybatis.spring.sqlSessionfactorybean">
		<property name="dataSource" ref="datasource"></property>
		<property name="configLocation" value="classpath:mybatis-config.xml"></property>
	</bean>
</beans>


ActionContext

<beans xmlns="http://www.springframework.org/schema/beans"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xsi:schemaLocation="http://www.springframework.org/schema/beans     
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">  


Struts2

<?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.objectFactory" value="spring"></constant>
	<package name="ajax" extends="json-default">
		<action name="StudentAction" class="StudentAction">
			<result name="json">
				<param name="root">students</param>
			</result>
			<result name="error">
				<param name="root">errMsg</param>
			</result>
		</action>
	</package>
</struts>

mybatis.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.2//EN" 
"http://mybatis.org/dtd/mybatis-3-config.dtd">

<configuration>
	<typeAliases>
		<typeAlias type="com.school.bean.Student" alias="Student"/>
		<typeAlias type="com.school.bean.Cls" alias="Cls"/>
		<typeAlias type="com.school.bean.Teacher" alias="Teacher"/>
		<typeAlias type="com.school.bean.AttendClsBean" alias="AttendClsRecord"/>
	</typeAliases>
	
	<mappers>
		<mapper resource="com.school.dao.mapper.studentMapper.xml"/>
	</mappers>
</configuration>

web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
id="WebApp_ID" 
version="3.0">
  <display-name>SSM1</display-name>
  	<context-param>  
	    <param-name>contextConfigLocation</param-name>  
	    <param-value>classpath:com/school/config/*.xml</param-value>  
	</context-param>
  	<context-param>
		<param-name>log4jConfigLocation</param-name>
		<param-value>classpath:com/school/config/log4j-config.properties</param-value>
	</context-param> 
	<context-param>
		<param-name>log4jRefreshInterval</param-name>
		<param-value>60000</param-value>
	</context-param>
	
	<listener>
		<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
	</listener> 
	
  	<listener>  
    	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
  	</listener>  
  
 	<!-- struts 2 configuration  -->
   <filter>
   		<filter-name>struts2</filter-name>
   		<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
   		<init-param>
   			<param-name>actionPackages</param-name>
   			<param-value>com.smart.action</param-value>
   		</init-param>
   </filter>
   <filter-mapping>
   		<filter-name>struts2</filter-name>
   		<url-pattern>/*</url-pattern>
   </filter-mapping>
  
  <!-- sitemesh configuration -->
  <filter>
  	<filter-name>sitemesh</filter-name>
  	<filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
  </filter>
  
  <filter-mapping>
  	<filter-name>sitemesh</filter-name>
  	<url-pattern>/*</url-pattern>
  </filter-mapping>
  
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>

sitemesh

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

<decorators defaultdir="/decorators">
	<excludes></excludes>
	<decorator name="main" page="/decorator/main.jsp">  
        <pattern>/*</pattern>  
    </decorator>   
</decorators>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念
xml文件介绍及使用
xml编程(一)-xml语法
XML文件结构和基本语法
第2章 包装类
XML入门的常见问题(二)
Java对象的强、软、弱和虚引用
JS解析XML文件和XML字符串详解
java中枚举的详细使用介绍
了解Xml格式
XML入门的常见问题(四)
深入SQLite多线程的使用总结详解
PlayFramework完整实现一个APP(一)
XML和YAML的使用方法
XML轻松学习总节篇