SPR-5766 - @ResponseBody

This commit is contained in:
Arjen Poutsma
2009-05-25 10:28:36 +00:00
parent af56f6497c
commit 6cb7f2cfc8
5 changed files with 86 additions and 6 deletions

View File

@@ -86,6 +86,7 @@ import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.support.WebArgumentResolver;
import org.springframework.web.bind.support.WebBindingInitializer;
@@ -868,11 +869,11 @@ public class ServletAnnotationControllerTests {
}
@Test
public void requestBody() throws ServletException, IOException {
public void requestBodyResponseBody() throws ServletException, IOException {
initServlet(RequestBodyController.class);
MockHttpServletRequest request = new MockHttpServletRequest("PUT", "/something");
String requestBody = "Hello World";
String requestBody = "H<EFBFBD>ll<EFBFBD> W<EFBFBD>rld";
request.setContent(requestBody.getBytes("UTF-8"));
request.addHeader("Content-Type", "text/plain; charset=utf-8");
MockHttpServletResponse response = new MockHttpServletResponse();
@@ -1561,8 +1562,9 @@ public class ServletAnnotationControllerTests {
public static class RequestBodyController {
@RequestMapping(value = "/something", method = RequestMethod.PUT)
public void handle(@RequestBody String body, Writer writer) throws IOException {
writer.write(body);
@ResponseBody
public String handle(@RequestBody String body) throws IOException {
return body;
}
}