81,095
社区成员
发帖
与我相关
我的任务
分享
<?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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<!-- 配置注解扫描路径 -->
<context:component-scan base-package="com.abc"></context:component-scan>
<!-- 配置注解驱动 -->
<mvc:annotation-driven></mvc:annotation-driven>
<!-- 第一步:创建dataSource对象(使用dbcp数据源)来连接数据库,这里创建好的对象在下面几步都要用到 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<!-- 设置驱动 -->
<property name="driverClassName" value="oracle.jdbc.OracleDriver"></property>
<!-- 设置url -->
<property name="url" value="jdbc:oracle:thin:@localhost:1521:orcl"></property>
<!-- 设置用户名 -->
<property name="username" value="Dragon"></property>
<!-- 设置密码 -->
<property name="password" value="monster"></property>
<!-- 设置最大连接数(可不写) -->
<property name="maxActive" value="50"></property>
<!-- 设置最大空闲数(可不写) -->
<property name="maxIdle" value="5"></property>
</bean>
<!-- 第二步:利用第一步创建的连接数据库的对象dataSource来创建sqlSesssionFactory对象 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!--将第一步创建的连接数据库的对象dataSource 注入进来 -->
<property name="dataSource" ref="dataSource"></property>
</bean>
<!-- 第三步: 利用第二步创建的SqlSessionFactory对象来创建Mapper对象。使用MapperScannerConfigurer对象批量扫描包来创建mapper对象
注意:创建出来的mapper对象id为接口名变成首字母小写之后的字符串
-->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!--将第二步创建好的SqlSessionFactory对象注入进来 -->
<property name="sqlSessionFactory" ref="sqlSessionFactory"></property>
<!-- 设置扫描路径 -->
<property name="basePackage" value="com.abc.dao"></property>
</bean>
</beans>
[/quote]
7楼正解<?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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<!-- 配置注解扫描路径 -->
<context:component-scan base-package="com.abc"></context:component-scan>
<!-- 配置注解驱动 -->
<mvc:annotation-driven></mvc:annotation-driven>
<!-- 第一步:创建dataSource对象(使用dbcp数据源)来连接数据库,这里创建好的对象在下面几步都要用到 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<!-- 设置驱动 -->
<property name="driverClassName" value="oracle.jdbc.OracleDriver"></property>
<!-- 设置url -->
<property name="url" value="jdbc:oracle:thin:@localhost:1521:orcl"></property>
<!-- 设置用户名 -->
<property name="username" value="Dragon"></property>
<!-- 设置密码 -->
<property name="password" value="monster"></property>
<!-- 设置最大连接数(可不写) -->
<property name="maxActive" value="50"></property>
<!-- 设置最大空闲数(可不写) -->
<property name="maxIdle" value="5"></property>
</bean>
<!-- 第二步:利用第一步创建的连接数据库的对象dataSource来创建sqlSesssionFactory对象 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!--将第一步创建的连接数据库的对象dataSource 注入进来 -->
<property name="dataSource" ref="dataSource"></property>
</bean>
<!-- 第三步: 利用第二步创建的SqlSessionFactory对象来创建Mapper对象。使用MapperScannerConfigurer对象批量扫描包来创建mapper对象
注意:创建出来的mapper对象id为接口名变成首字母小写之后的字符串
-->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!--将第二步创建好的SqlSessionFactory对象注入进来 -->
<property name="sqlSessionFactory" ref="sqlSessionFactory"></property>
<!-- 设置扫描路径 -->
<property name="basePackage" value="com.abc.dao"></property>
</bean>
</beans>
<c:set var="base" scope="request" value="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}" />
在你引用css,js文件的时候,加上这个${base}就好了