tan*_*ane 0 java xml spring spring-mvc
我想补充CSS和JS对JSP页面中的spring MVC,这样我已经包括的参考项目js/css文件夹中dispatcher-servlet.xml,如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
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/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
<context:annotation-config />
<context:component-scan base-package="com.asurion" />
<resources mapping="/js/**" location="/js/" />
<resources mapping="/css/**" location="/css/" />
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</beans:bean>
<beans:bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:messages" />
<property name="defaultEncoding" value="UTF-8" />
</beans:bean>
<beans:bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
p:location="/WEB-INF/jdbc.properties" />
<beans:bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
p:driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
p:url="jdbc:sqlserver://localhost:1433;DataBaseName=test" p:username="test"
p:password="test" />
<beans:bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
<property name="configurationClass">
<value>org.hibernate.cfg.AnnotationConfiguration</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">com.asurion.dialect.SQlServerDBDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</beans:bean>
<beans:bean id="reportDAO" class="com.asurion.dao.ReportDaoImpl"></beans:bean>
<beans:bean id="reportManager" class="com.asurion.service.ReportManagerImpl"></beans:bean>
<tx:annotation-driven />
<beans:bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</beans:bean>
</beans:beans>
Run Code Online (Sandbox Code Playgroud)
但它显示"前缀"bean"for element"bean:bean"未绑定"在spring配置文件中,所以任何人都可以帮我解决这个问题吗?
看看你的根元素声明-您所指定的前缀命名空间mvc,xsi,context,p,和tx,但没有进行beans.您已经创建"http://www.springframework.org/schema/beans"了默认命名空间,但是您没有给它一个别名beans.
这里最简单的解决方法可能只是进行搜索并替换以beans:从整个文件中删除- 只需将默认设置放到其工作中即可.
或者,改变这个:
xmlns="http://www.springframework.org/schema/beans"
Run Code Online (Sandbox Code Playgroud)
至
xmlns:beans="http://www.springframework.org/schema/beans"
Run Code Online (Sandbox Code Playgroud)
...然后检查每个没有显式名称空间前缀的元素,看看你是否真的想要它beans.例如,考虑:
<resources mapping="/js/**" location="/js/" />
Run Code Online (Sandbox Code Playgroud)
如果您使用显式命名空间,那可能应该是
<beans:resources mapping="/js/**" location="/js/" />
Run Code Online (Sandbox Code Playgroud)
虽然这听起来像它应该实际上是
<mvc:resources mapping="/js/**" location="/js/" />
Run Code Online (Sandbox Code Playgroud)
目前默认情况下它位于beans命名空间中,但默认和使用beans:前缀的混合非常令人困惑......
| 归档时间: |
|
| 查看次数: |
6861 次 |
| 最近记录: |