开发者

How can I make the communication between two web apps using UrlConnection?

开发者 https://www.devze.com 2023-04-11 02:32 出处:网络
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.

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..? Wh开发者_StackOverflow社区at the client request url should look like?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号