gpt4 book ai didi

java - 元素 "beans"的前缀 "beans:beans"未绑定(bind)

转载 作者:行者123 更新时间:2023-12-01 07:20:42 28 4
gpt4 key购买 nike

我正在尝试将 CSSJS 添加到 spring MVC 项目中的 JSP 页面,以便我在 dispatcher-servlet.xml 中包含了 js/css 文件夹的引用,如下所示:

<?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>

但它在 spring 配置文件本身中显示“元素“beans:beans”的前缀“beans”未绑定(bind)”,所以有人可以帮我解决这个问题吗?

最佳答案

查看您的根元素声明 - 您已为前缀 mvcxsicontextp< 指定了命名空间 和 tx,但对于 beans 没有任何内容。您已将“http://www.springframework.org/schema/beans”设为默认命名空间,但尚未为其指定beans别名。

这里最简单的修复可能只是进行搜索并替换以从整个文件中删除 beans: - 只需让默认值发挥作用即可。

或者,更改此:

xmlns="http://www.springframework.org/schema/beans"

xmlns:beans="http://www.springframework.org/schema/beans"

...然后检查每个没有显式 namespace 前缀的元素,看看您是否实际上认为它是bean。例如,考虑:

<resources mapping="/js/**" location="/js/" />

如果您使用显式命名空间,那可能应该是

<beans:resources mapping="/js/**" location="/js/" />

尽管听起来实际上应该是

<mvc:resources mapping="/js/**" location="/js/" />

目前默认情况下它位于 beans 命名空间中,但是默认和使用 beans: 前缀的混合非常令人困惑......

关于java - 元素 "beans"的前缀 "beans:beans"未绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38656605/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com