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>原文链接:https://www.f2er.com/xml/298501.html