gpt4 book ai didi

java - Spring MVC + GWT RPC

转载 作者:太空宇宙 更新时间:2023-11-04 06:28:14 25 4
gpt4 key购买 nike

我有一个应用程序,前端使用 GWT,后端使用 Spring。我正在尝试使用 Spring MVC 添加一个简单的页面,但映射存在一些问题。

我已经创建了 Controller :

@Controller
@RequestMapping("/jobrunner.rpc")
public class JobRunnerController {

@RequestMapping(method = RequestMethod.GET)
public String getStartPage() {
return "jobrunner";
}
}

当我启动我的应用程序时,有一行关于映射的内容:[DefaultAnnotationHandlerMapping.registerHandler(411)] 将 URL 路径 [/jobrunner.rpc] 映射到处理程序“jobRunnerController”

但是当我尝试打开此页面时,我有 404 页面和日志中的下一行:[PageNotFound.noHandlerFound(947)] 在名为“spring-rpc”的 DispatcherServlet 中未找到带有 URI [/rds/jobrunner.rpc] 的 HTTP 请求的映射

也许,web.xml 及其过滤器有问题?这是:

<session-config>
<session-timeout>15</session-timeout>
</session-config>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<listener>
<listener-class>com.db.gbs.gbsapps.rds.backend.servlet.listener.StartupListener</listener-class>
</listener>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/application-config.xml</param-value>
</context-param>

<filter>
<filter-name>AuthenticationFilter</filter-name>
<filter-class>com.gft.riaframework.backend.api.filters.AuthenticationFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>AuthenticationFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>



<filter>
<filter-name>AuthorizationFilter</filter-name>
<filter-class>com.db.gbs.gbsapps.rds.backend.services.security.impl.live.CustomAuthorizationFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>AuthorizationFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<filter>
<filter-name>ExpiryFilter</filter-name>
<filter-class>com.db.gm.adk.server.filter.ExpiryFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ExpiryFilter</filter-name>
<url-pattern>*.html</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>ExpiryFilter</filter-name>
<url-pattern>*.css</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>ExpiryFilter</filter-name>
<url-pattern>*.js</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>ExpiryFilter</filter-name>
<url-pattern>*.gif</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>ExpiryFilter</filter-name>
<url-pattern>*.png</url-pattern>
</filter-mapping>

<filter>
<filter-name>GZIPFilter</filter-name>
<filter-class>com.db.gm.adk.server.filter.GZIPFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>GZIPFilter</filter-name>
<url-pattern>*.html</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>GZIPFilter</filter-name>
<url-pattern>*.css</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>GZIPFilter</filter-name>
<url-pattern>*.js</url-pattern>
</filter-mapping>

<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<filter>
<filter-name>NoCacheFilter</filter-name>
<filter-class>com.db.gbs.gbsapps.rds.backend.servlet.filter.NoCacheFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>NoCacheFilter</filter-name>
<url-pattern>/index.html</url-pattern>
</filter-mapping>

<servlet>
<servlet-name>spring-rpc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring-rpc</servlet-name>
<url-pattern>*.rpc</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>eventServiceImpl</servlet-name>
<servlet-class>de.novanic.eventservice.service.EventServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>eventServiceImpl</servlet-name>
<url-pattern>/main/gwteventservice</url-pattern>
</servlet-mapping>

<error-page>
<error-code>500</error-code>
<location>/WEB-INF/jsp/error.jsp</location>
</error-page>

<error-page>
<error-code>503</error-code>
<location>/WEB-INF/jsp/error.jsp</location>
</error-page>

<error-page>
<error-code>403</error-code>
<location>/WEB-INF/jsp/403.jsp</location>
</error-page>

<error-page>
<error-code>404</error-code>
<location>/WEB-INF/jsp/404.jsp</location>
</error-page>

<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/WEB-INF/jsp/error.jsp</location>
</error-page>

预先感谢您的建议。

最佳答案

很可能是您使用的后缀“.rpc”有问题

尝试在没有“.rpc”的情况下进行映射

查看 spring 引用

http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#mvc-ann-requestmapping-suffix-pattern-match

Path Pattern Matching By Suffix

By default Spring MVC automatically performs "." suffix pattern matching so that a controller mapped to /person is also implicitly mapped to /person.. This allows indicating content types via file extensions, e.g. /person.pdf, /person.xml, etc. A common pitfall however is when the last path segment of the mapping is a URI variable, e.g. /person/{id}. While a request for /person/1.json would correctly result in path variable id=1 and extension ".json", when the id naturally contains a dot, e.g. /person/joe@email.com the result does not match expectations. Clearly here ".com" is not a file extension.

The proper way to address this is to configure Spring MVC to only do suffix pattern matching against file extensions registered for content negotiation purposes. For more on this, first see Section 17.16.4, “Content Negotiation” and then Section 17.16.9, “Path Matching” showing how to enable suffix pattern matching along with how to use registered suffix patterns only.

关于java - Spring MVC + GWT RPC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26482756/

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