我有一个使用休息服务实现的服务器 Web 应用程序,我想制作一个客户端 Web 应用程序。我必须使用 UrlConnection 进行通信,但我真的不知道如何进行。
我的服务器应用程序如下所示:
@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);
}
}
到目前为止,我已经在 jsp 页面“人”中看到了结果,但现在我需要介绍客户端应用程序。我的控制器应该以 json 格式返回数据,该数据将发送给客户端,客户端将在 Html 页面中呈现信息。但是我怎样才能在@RequestMapping(method = RequestMethod.GET, value = "/person/{id}")
和客户端请求之间建立连接..?客户端请求 url 应该是什么样的?