- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 Grails 后端,其中一个 Flex 单页应用程序充当 UI。由于某种原因,当我发出 AMF 请求时,我的应用程序出现问题。出现以下错误(为了便于阅读,部分内容被截断)
2014-04-20 21:07:55,572 [http-bio-8080-exec-6] ERROR errors.GrailsExceptionResolver -
ClassCastException occurred when processing request: [POST]
/OrlandoGrails/messagebroker/amf
org.springframework.web.context.request.ServletRequestAttributes cannot be cast to
org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequest. Stacktrace follows:
java.lang.ClassCastException:
org.springframework.web.context.request.ServletRequestAttributes cannot be cast to
org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequest...
2014-04-20 21:07:55,573 [http-bio-8080-exec-6] ERROR errors.GrailsExceptionResolver -
Unable to render errors view:
org.springframework.web.context.request.ServletRequestAttributes cannot be cast to
org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequest...
java.lang.ClassCastException:
org.springframework.web.context.request.ServletRequestAttributes cannot be cast to
org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequest
Servlet.service() for servlet [Spring MVC Dispatcher Servlet] in context with path
[/OrlandoGrails] threw exception [Request processing failed; nested exception is
org.codehaus.groovy.grails.exceptions.GrailsRuntimeException:
java.lang.ClassCastException:
org.springframework.web.context.request.ServletRequestAttributes cannot be cast to
org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequest] with root cause...
java.lang.ClassCastException:
org.springframework.web.context.request.ServletRequestAttributes cannot be cast to
org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequest at
grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53
我已经阅读了网络上的一些其他解决方案,他们说我必须首先使用 springSecurityFilter 订购 web.xml,最后进行映射。我已经这样做了,下面是我的 web.xml 模板(在 Grails 掌握它之前)
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
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_3_0.xsd">
<display-name>/@grails.project.key@</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>@grails.project.key@</param-value>
</context-param>
<listener>
<listener-class>org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener</listener-class>
</listener>
<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>
<servlet>
<servlet-name>grails</servlet-name>
<servlet-class>org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet</servlet-class>
<init-param>
<param-name>dispatchOptionsRequest</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</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>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.gsp</welcome-file>
</welcome-file-list>
<listener>
<listener-class>flex.messaging.HttpFlexSession</listener-class>
</listener>
<servlet>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/web-application-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<url-pattern>/messagebroker/*</url-pattern>
</servlet-mapping>
正在访问的 URL 是/blah/messagebroker/amf,所以我本以为只有 blazeds messagebroker 处理程序才能收到请求,但显然我错了。
非常感谢对此的任何帮助。
最佳答案
由于 web.xml 中的文档排序,charEncodingFilter
将始终在 sitemesh
过滤器之前执行。
我正在推测,但当 sitemesh
过滤器时,由 charEncodingFilter
创建的 ServletRequestAttribute
实例似乎被转换为错误的类型被执行。
您是否尝试过交换过滤器映射
的位置?像这样的东西:
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>charEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
关于servlets - Grails Servlet 过滤器疯狂 : . ..ServletRequestAttributes 无法转换为 ..GrailsWebRequest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23190332/
当从 ServletRequestAttributes 对象请求属性值时,如何知道为 scope 参数赋予什么值? 特别是,我想获取发送到 this GitHub example app 授权端点的请
我有一个 Grails 后端,其中一个 Flex 单页应用程序充当 UI。由于某种原因,当我发出 AMF 请求时,我的应用程序出现问题。出现以下错误(为了便于阅读,部分内容被截断) 2014-04-2
我正在使用 SpringBoot 1.5.2 版本。我有一个异步 REST 调用,它会生成单独的 java 线程来完成长时间运行的作业。长时间运行的作业需要更新数据库表,我将 Spring 审核 be
从 Spring 3 迁移到 Spring 4 后,请求页面时出现以下错误: java.lang.NoSuchMethodError: org.springframework.web.context.
我是一名优秀的程序员,十分优秀!