Announcement Announcement Module
Collapse
No announcement yet.
server can't get the data posted by android restTemplate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • server can't get the data posted by android restTemplate


    hi,I invoke restTemplate's postForEntity to post two string to server;
    client 's code like this:



    map = new LinkedMultiValueMap<String, String>();
    map.clear();
    map.add("uid", user.uid);
    map.add("isbn", book.getIsbn());
    ResponseEntity<String> response = rest.postForEntity(url, map, String.class);


    server's code is:

    String readerID = request.getParameter("uid");
    String isbn = request.getParameter("isbn");


    the readerID and isbn is null ;

    I read the code in spring-android-sample-showcase-server
    i know that use the spring MVC 's anotation @RequestMapping
    like this:


    Code:
    @RequestMapping(value = "sendmessagemap", method = RequestMethod.POST)
        public @ResponseBody String sendMessageMap(@RequestBody LinkedMultiValueMap<String, String> map)
    is this the only way to get data which posted from client ?
    if i use restTemplate post data to server, if server want to get data, the only way is spring MVC?

  • #2
    Hi, thanks for your interest in Spring for Android. Spring MVC is a fully featured web framework that can be used to build modern web sites. We use it in our samples because we like it, and we built it. However, there are many web frameworks available and you are not required to use Spring MVC when sending data with Spring for Android. RestTemplate simply provides a convenient abstraction around standard HTTP functions which most web frameworks are capable of handling.

    Comment


    • #3
      thank you

      Originally posted by Roy Clarkson View Post
      Hi, thanks for your interest in Spring for Android. Spring MVC is a fully featured web framework that can be used to build modern web sites. We use it in our samples because we like it, and we built it. However, there are many web frameworks available and you are not required to use Spring MVC when sending data with Spring for Android. RestTemplate simply provides a convenient abstraction around standard HTTP functions which most web frameworks are capable of handling.
      thank you ,i know how to slove my problem from here!
      HTML Code:
      http://forum.springsource.org/showthread.php?97600-How-to-use-RestTemplate-post-value-object-with-customized-headers
      , I think if you use spring-android from client, you should use spring-mvc for srever better;

      Comment

      Working...
      X