我正在尝试调用 Spring Web 服务,在浏览器中使用下面的 url 服务“myservice”应该返回 XML,即基于 @RequestMapping 注释,下面的 URL 是否正确?
> http://localhost:8080/mywebapp/myservice/feeds/allFeeds.xml/
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("myservice")
public class TheController {
private TheService TheServiceWS;
public TheController(TheService TheServiceWS) {
this.TheServiceWS = TheServiceWS;
}
@RequestMapping(value = "feeds/allFeeds.xml", produces = MediaType.APPLICATION_XML_VALUE)
@ResponseBody
public String getValues() {
return TheServiceWS.getAllFeeds();
}
}