Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我能';不要在servlet上下文XML中使用Spring过滤器_Java_Spring - Fatal编程技术网

Java 我能';不要在servlet上下文XML中使用Spring过滤器

Java 我能';不要在servlet上下文XML中使用Spring过滤器,java,spring,Java,Spring,出于某种原因,Eclipse和Spring都找不到过滤器标签(甚至还有一个红色标记)。。。怎么了 <?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:mvc="http://www.springframewo

出于某种原因,Eclipse和Spring都找不到过滤器标签(甚至还有一个红色标记)。。。怎么了

<?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:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/aop 
        http://www.springframework.org/schema/aop/spring-aop-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/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">


    <bean
        class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"></bean>

    <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource"
        destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url" value="jdbc:mysql://localhost/jacciseweb" />
        <property name="username" value="root" />
        <property name="password" value="siussi" />
    </bean>


    <bean id="mySessionFactory"
        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="myDataSource" />
        <property name="annotatedClasses">
            <list>
                <value>it.jsoftware.jacciseweb.beans.Utente
                </value>
                <value>it.jsoftware.jacciseweb.beans.Ordine
                </value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect
                </prop>
                <prop key="hibernate.show_sql">
                    true
                </prop>
                <prop key="hibernate.hbm2ddl.auto">
                    update
                </prop>
                <prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>
            </props>
        </property>
    </bean>



    <filter>
        <filter-name>hibernateFilter</filter-name>
        <filter-class>
            org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
        </filter-class>
        <init-param>
            <param-name>singleSession</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>sessionFactoryBeanName</param-name>
            <param-value>mySessionFactory</param-value>
        </init-param>
    </filter>


    <!-- <aop:config> -->
    <!-- <aop:pointcut id="productServiceMethods" -->
    <!-- expression="execution(* product.ProductService.*(..))" /> -->
    <!-- <aop:advisor advice-ref="txAdvice" pointcut-ref="productServiceMethods" 
        /> -->
    <!-- </aop:config> -->



    <bean id="acciseHibernateDao"
        class="it.jsoftware.jacciseweb.model.JAcciseWebManagementDaoHibernate">
        <property name="sessionFactory" ref="mySessionFactory" />
    </bean>


    <bean id="transactionManager"
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="mySessionFactory" />
    </bean>

    <tx:annotation-driven />

    <bean id="acciseService"
        class="it.jsoftware.jacciseweb.model.JAcciseWebManagementServiceImpl">
        <property name="dao" ref="acciseHibernateDao" />
    </bean>

    <context:component-scan base-package="it.jsoftware.jacciseweb.controllers"></context:component-scan>
    <mvc:annotation-driven />
    <bean
        class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"
        p:synchronizeOnSession="true" />

    <bean
        class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />

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

    <!-- non serve, è annotato -->
    <!-- <bean name="/accise" class="it.jsoftware.jacciseweb.controllers.MainController"> 
        </bean> -->



</beans>

it.jsoftware.jacciseweb.beans.utete
it.jsoftware.jacciseweb.beans.Ordine
org.hibernate.dialogue.mysqldialogue
真的
更新
org.hibernate.cache.NoCacheProvider
冬眠过滤器
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
单一会话
真的
sessionFactoryBeanName
mySessionFactory
特别是它说“过滤器”是无效的内容

应该放在
web.xml
中,而不是放在Spring的xml配置中

基本上,您需要在
web.xml
中使用它:

<web-app>
...
    <filter>
        <filter-name>hibernateFilter</filter-name>
        <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>    
        <init-param>
            <param-name>singleSession</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>sessionFactoryBeanName</param-name>
            <param-value>mySessionFactory</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>hibernateFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
...
</web-app>

...
冬眠过滤器
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
单一会话
真的
sessionFactoryBeanName
mySessionFactory
冬眠过滤器
/*
...

Servlet过滤器属于
web.xml
,而不是您的Spring上下文

如果您想要OpenSessionInView逻辑,那么可以使用
OpenSessionInviewWinterCeptor
(而不是
OpenSessionInViewFilter
),它会出现在Spring配置中

有关如何注册拦截器的信息,请参阅