grails hdiv integration - 会话成功但得到HDIV_PARAMETER_NOT_EXISTS异常

时间:2012-05-31 22:53:52

标签: spring grails spring-security hdiv

我正在尝试将hdiv集成到grails 2.0.3应用程序中。

我在grails应用程序中为spring mvc做了hdiv-reference doc中提到的所有更改。 当应用程序启动时,我可以看到hdiv validatorfilter已初始化并且已创建Hdiv会话。

感谢任何帮助

巴拉

在我的applicationcontext.xml中,我有

<bean id="requestDataValueProcessor" class="org.hdiv.web.servlet.support.HdivRequestDataValueProcessor" />

我的web.xml是

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
         metadata-complete="true"
         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_2_5.xsd">

    <display-name>/@grails.project.key@</display-name>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml,/WEB-INF/hdiv-config.xml,/WEB-INF/hdiv-validations.xml</param-value>
    </context-param>

    <context-param>
        <param-name>webAppRootKey</param-name>
        <param-value>@grails.project.key@</param-value>
    </context-param>

  <!-- HDIV Validator Filter -->
    <filter>
        <filter-name>ValidatorFilter</filter-name>
        <filter-class>org.hdiv.filter.ValidatorFilter</filter-class>
    </filter>

    <filter>
        <filter-name>sitemesh</filter-name>
        <filter-class>org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter</filter-class>
    </filter>

    <filter>
        <filter-name>charEncodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        <init-param>
            <param-name>targetBeanName</param-name>
            <param-value>characterEncodingFilter</param-value>
        </init-param>
        <init-param>
            <param-name>targetFilterLifecycle</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>charEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>sitemesh</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>ERROR</dispatcher>
    </filter-mapping>

    <filter-mapping>
        <filter-name>ValidatorFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>


    <listener>
        <listener-class>org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener</listener-class>
    </listener>

<!-- HDIV Listener class -->
    <listener>
        <listener-class>org.hdiv.listener.InitListener</listener-class>
    </listener>

    <!-- Grails dispatcher servlet -->
    <servlet>
        <servlet-name>grails</servlet-name>
        <servlet-class>org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <!-- The Groovy Server Pages servlet -->
    <servlet>
        <servlet-name>gsp</servlet-name>
        <servlet-class>org.codehaus.groovy.grails.web.pages.GroovyPagesServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>gsp</servlet-name>
        <url-pattern>*.gsp</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <!--
        The order of the welcome pages is important.  JBoss deployment will
        break if index.gsp is first in the list.
        -->
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>index.gsp</welcome-file>
    </welcome-file-list>

    <jsp-config>
        <taglib>
            <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
            <taglib-location>/WEB-INF/tld/c.tld</taglib-location>
        </taglib>
        <taglib>
            <taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
            <taglib-location>/WEB-INF/tld/fmt.tld</taglib-location>
        </taglib>
        <taglib>
            <taglib-uri>http://www.springframework.org/tags</taglib-uri>
            <taglib-location>/WEB-INF/tld/spring.tld</taglib-location>
        </taglib>

        <taglib>
                    <taglib-uri>http://grails.codehaus.org/tags</taglib-uri>
                    <taglib-location>/WEB-INF/tld/grails.tld</taglib-location>
                </taglib>        
        <taglib>
            <taglib-uri>http://www.springframework.org/tags/form</taglib-uri>
            <taglib-location>/WEB-INF/tld/spring-form.tld</taglib-location>
        </taglib>
    </jsp-config>

</web-app>

我的hdiv-config.xml是

<?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:hdiv="http://www.hdiv.org/schema/hdiv"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.hdiv.org/schema/hdiv http://www.hdiv.org/schema/hdiv/hdiv.xsd">

    <hdiv:config errorPage="/error.jsp">
        <hdiv:startPages>/,/attacks/.*,/index.gsp</hdiv:startPages>
    </hdiv:config>

</beans>

但是我看到了错误

 2012-05-31 15:10:22,704 [pool-5-thread-1] DEBUG filter.ValidatorFilter  - Initializing filter 'ValidatorFilter'
    2012-05-31 15:10:22,705 [pool-5-thread-1] DEBUG filter.ValidatorFilter  - Filter 'ValidatorFilter' configured successfully
| Server running. 
2012-05-31 15:10:32,912 [http-bio-8080-exec-2] INFO  listener.InitListener  - HDIV's session created:39414F37F6E68615298D1B7B6FD4B3A0
2012-05-31 15:10:32,925 [http-bio-8080-exec-2] INFO  **logs.Logger  - HDIV_PARAMETER_NOT_EXISTS;/TestHdiv/author/index;_HDIV_STATE_;null;0:0:0:0:0:0:0:1;0:0:0:0:0:0:0:1;user**
2012-05-31 15:10:32,925 [http-bio-8080-exec-2] DEBUG dataComposer.DataComposerMemory  - The page [14] has no states, is not stored in session
2012-05-31 15:10:32,985 [http-bio-8080-exec-3] DEBUG dataComposer.DataComposerMemory  - The page [15] has no states, is not stored in session

1 个答案:

答案 0 :(得分:0)

根据HDIV的installation documentation,可以试试这个:

<filter-mapping>
    <filter-name>ValidatorFilter</filter-name>
    <!-- Grails dispatcher servlet -->
    <servlet-name>grails</servlet-name>
</filter-mapping>

您可能还需要添加gsp servlet映射,但我会首先尝试使用grails前端控制器。

<filter-mapping>
    <filter-name>ValidatorFilter</filter-name>
    <!-- Grails dispatcher servlet -->
    <servlet-name>grails</servlet-name>
    <!-- Groovy Server Pages servlet -->
    <servlet-name>gsp</servlet-name>
</filter-mapping>