该帖已经被评为精华帖
|
|
---|---|
作者 | 正文 |
发表时间:2012-03-07
最后修改:2012-03-07
godson_2003 写道 Exception in thread "main" org.springframework.web.client.RestClientException: Cannot extract response: no Content-Type found
at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:56) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:352) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:307) at org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:234) at UserRestServiceClientTest.main(UserRestServiceClientTest.java:39) 37 form.add("sign", sign); 38 String response = null; 39 response = restTemplate.postForObject("http://localhost:8080/scm", form, String.class); System.out.println("response:\n" + response); response = restTemplate.postForObject("http://localhost:8080/scm", form, 改成: response = restTemplate.postForObject("http://localhost:8080/router", form, 因为ROP的RequestMapping设置为@RequestMapping("/router"): @RequestMapping("/router")//这是ROP的总入口 public void service(WebRequest webRequest, HttpServletResponse httpServletResponse) { ... } |
|
返回顶楼 | |
发表时间:2012-03-07
这是个好动西,粗略的看了一下,关于验证那块没用oauth么?
|
|
返回顶楼 | |
发表时间:2012-03-07
stamen 写道 godson_2003 写道 Exception in thread "main" org.springframework.web.client.RestClientException: Cannot extract response: no Content-Type found
at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:56) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:352) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:307) at org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:234) at UserRestServiceClientTest.main(UserRestServiceClientTest.java:39) 37 form.add("sign", sign); 38 String response = null; 39 response = restTemplate.postForObject("http://localhost:8080/scm", form, String.class); System.out.println("response:\n" + response); response = restTemplate.postForObject("http://localhost:8080/scm", form, 改成: response = restTemplate.postForObject("http://localhost:8080/router", form, 因为ROP的RequestMapping设置为@RequestMapping("/router"): @RequestMapping("/router")//这是ROP的总入口 public void service(WebRequest webRequest, HttpServletResponse httpServletResponse) { ... } 不依赖于web容器么?http://localhost:8080/router跟http://localhost:8080/scm/router都报404错误 2012-03-07 16:06:44,222 [main] WARN [org.springframework.web.client.RestTemplate] - POST request for "http://localhost:8080/scm/router" resulted in 404 (Not Found); invoking error handler Exception in thread "main" org.springframework.web.client.HttpClientErrorException: 404 Not Found at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:69) at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:392) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:349) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:307) at org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:234) at UserRestServiceClient.main(UserRestServiceClient.java:41) |
|
返回顶楼 | |
发表时间:2012-03-07
最后修改:2012-03-07
用jetty插件部署成功了
![]() 但是客户端运行没结果 ![]() |
|
返回顶楼 | |
发表时间:2012-03-07
godson_2003 写道 不依赖于web容器么?http://localhost:8080/router跟http://localhost:8080/scm/router都报404错误 2012-03-07 16:06:44,222 [main] WARN [org.springframework.web.client.RestTemplate] - POST request for "http://localhost:8080/scm/router" resulted in 404 (Not Found); invoking error handler Exception in thread "main" org.springframework.web.client.HttpClientErrorException: 404 Not Found at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:69) at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:392) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:349) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:307) at org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:234) at UserRestServiceClient.main(UserRestServiceClient.java:41) 要包含WebContext的上下文部署路径,你的web.xml有改吗,注意Spring servlet的配置: <servlet> <servlet-name>rop</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <load-on-startup>3</load-on-startup> </servlet> <servlet-mapping> <servlet-name>rop</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> DispatcherServlet拦截所有的请求,你可以把断言设置在AnnotationRopServiceRouter的service()方法里,看会不会到达那里,如果到达不了那里,肯定就是你web.xml配置的问题了。 |
|
返回顶楼 | |
发表时间:2012-03-07
部署成功了为什么我在UserRestService里面打断点,都无法进入
|
|
返回顶楼 | |
发表时间:2012-03-07
是啊,搞成maven project,就没那么大了
|
|
返回顶楼 | |
发表时间:2012-03-07
膜拜一下大仙,慢慢看
|
|
返回顶楼 | |
发表时间:2012-03-07
wensen 写道 是啊,搞成maven project,就没那么大了
呵呵 好的,接下来就改。 |
|
返回顶楼 | |
发表时间:2012-03-07
最后修改:2012-03-07
1. 确实应该用maven。
2. 貌似耦合性比较高。 看了看,还是不错的。有兴趣~ |
|
返回顶楼 | |