67,512
社区成员
发帖
与我相关
我的任务
分享
<?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:tx="http://www.springframework.org/schema/tx" 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/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
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- 数据库连接 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName"><value>oracle.jdbc.driver.OracleDriver</value> </property>
<property name="url"><value>jdbc:oracle:thin:@127.0.0.1:1521:orcl</value> </property>
<property name="username"> <value>myuser</value></property>
<property name="password"> <value>myuser</value> </property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<!-- 数据库连接 -->
<property name="dataSource">
<ref local="dataSource"/>
</property>
<!-- hibernate自身属性 -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
<!-- 解决no session found -->
<prop key="hibernate.current_session_context_class">thread</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>com.myssh.model.Userinfo</value>
</list>
</property>
</bean>
<!-- 用户Dao -->
<bean id="userDao" class="com.myssh.daoimpl.UserinfoDAOImpl" scope="singleton">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<!-- 用户Service -->
<bean id="userService" class="com.myssh.serviceimpl.UserinfoServiceImpl" scope="singleton">
<property name="userDao">
<ref local="userDao"/>
</property>
</bean>
<!-- 用户Action -->
<bean id="saveUserAction" class="com.myssh.controller.MyInsert" scope="prototype">
<property name="userService">
<ref local="userService"/>
</property>
</bean>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 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_3_0.xsd">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!-- struts2拦截器 -->
<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>
<!-- 创建spring工厂监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 告知spring context config location 的存储位置 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/applicationContext.xml</param-value>
</context-param>
</web-app>
不知道会不会是web.xml配置有问题,但是里面就这么几行呀。