0

I have a server web app implemented with rest services and I want to make a client web application. I have to make the communication using UrlConnection and I don't really know how to make it.

My server app looks like this:

@Controller
public class PersonController {

    private PersonDs personDs;

    public void setPersonDs(PersonDs ds) {
        this.personDs = ds;
    }

    @Secured(value = { "ROLE_ADMIN" }
    @RequestMapping(method = RequestMethod.GET, value = "/person/{id}")
    public ModelAndView getEmployee(@PathVariable String id) {
        Person e = personDs.get(id);
        return new ModelAndView("person", "object", e);
    }

}

Until now I have seen the result in a jsp page "person" but now I need to introduce the client app. My controller should return the data in a json format which will be sent to the client, and the client will render the information in a Html page. But how can I make the connection between @RequestMapping(method = RequestMethod.GET, value = "/person/{id}") and the client request..? What the client request url should look like?

Azim
  • 925
  • 11
  • 24
Any
  • 71
  • 1
  • 1
  • 3
  • Just the same URL as you have in your browser address bar when opening this by a normal webbrowser? As to using `URLConnection`, just check [How to use java.net.URLConnection to fire and handle HTTP requests?](http://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests) – BalusC Oct 05 '11 at 16:34
  • And for having multiple types of outputs from your server resource you can use Spring's ContentNegotiatingViewResolver to serve client as per its output type request. – sudmong Oct 05 '11 at 18:12

0 Answers0