我有一个问题,我的 Spring Rest 控制器以其他方式映射而不是 RestyGWT 想要的。我的申请在:http://localhost:8080/restgwt/
根据 web.xml:
<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/classes/action-servlet.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>/service/*</url-pattern>
</servlet-mapping>
我的 Spring 服务/控制器监听:
http://localhost:8080/restgwt/service/test
但是我的 RestyGWT 服务调用了这个 url:
http://localhost:8080/restgwt/restgwt/test
而且我不知道如何告诉 RestyGWT 改变url
。请帮忙。
我知道最简单的解决方案是更改web.xml
文件 servleturl-pattern
参数
从:<url-pattern>/service/*</url-pattern>
至:<url-pattern>/restgwt/*</url-pattern>
但我想让 RestyGWT 改变它的行为。
这里粘贴一些额外的代码:
GWT 端的 TestService
package pl.korbeldaniel.restgwt.client;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import org.fusesource.restygwt.client.MethodCallback;
import org.fusesource.restygwt.client.RestService;
public interface TestService extends RestService {
@GET
@Path("test")
public void getInfo(MethodCallback<TestPojo> test);
}
Spring 端的 TestService
package pl.korbeldaniel.restgwt.server;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@RestController()
public class TestService {
@RequestMapping(value = "test", method = RequestMethod.GET)
public @ResponseBody TestEntity getInfo() {
TestEntity test = new TestEntity();
System.out.println("Hit server for getting _1");
return new TestEntity();
}
}