OpenSessionInView 过滤器导致 grails run-app 崩溃?
我使用 OpenSessionInView 和 DWR 来为我的 ajax 请求获取休眠会话。当我开始部署战争时,这工作正常,但是当我尝试使用 run-app
运行时,我收到以下错误:
ERROR: org.apache.catalina.startup.ContextConfig -文件中的应用程序 web.xml 文件中的解析错误:/C:/Users/stefan/.grails/1.3.6/projects/myproject/resources/web.xml java.lang.IllegalArgumentException:过滤器映射指定未知的过滤器名称hiddenHttpMethod
web.xml
<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>
</filter>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>/dwr/*</url-pattern>
</filter-mapping>
我尝试添加hiddenHttpMethod
过滤器映射,但出现相同的错误。这是怎么回事?
添加失败的条目:
<filter>
<filter-name>hiddenHttpMethod</filter-name>
<filter-class>org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>hiddenHttpMethod</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
I'm using OpenSessionInView with DWR to get a hibernate session for my ajax requests. This works fine when I start through a deployed war, but when I try to run with run-app
, I get the following error:
ERROR: org.apache.catalina.startup.ContextConfig - Parse error in application web.xml file at file:/C:/Users/stefan/.grails/1.3.6/projects/myproject/resources/web.xml
java.lang.IllegalArgumentException: Filter mapping specifies an unknown filter name hiddenHttpMethod
web.xml
<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>
</filter>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>/dwr/*</url-pattern>
</filter-mapping>
I tried adding the hiddenHttpMethod
filter mapping, but I get the same error. What's going on?
Added entries which failed:
<filter>
<filter-name>hiddenHttpMethod</filter-name>
<filter-class>org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>hiddenHttpMethod</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很奇怪,但是您需要将多个
web.xml
条目添加到文件顶部,因为过滤器顺序很重要。将其添加到过滤器顶部附近:
但是请注意,这会将 reloadFilter 添加到您的生产战争中。您可以通过拦截
webXml
事件来删除它,但这很痛苦。Very odd, but you need to add multiple
web.xml
entries to the top of the file, as the filter order is important.Add this near the top of your filters:
Note, however, that this adds the reloadFilter to your production war. You can remove this by intercepting the
webXml
events, but that's a pain.