-1
我使用的球衣,我試圖訪問我的方法要求身體非常類似於這樣的問題:得到正文內容@Context HttpServletRequest的java的球衣
我如何讀取請求體使用澤西RESTful服務?
身體價值寄給我與郵遞員。
@Path("/updateanfrage")
public class UpdateAnfrage extends ResourceConfig
{
private static final Logger log = Logger.getLogger(UpdateAnfrage.class);
@POST
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_XML)
public UpdateInformation beschaffeUpdateInformation(ClientInformation clientinformation,
@Context HttpHeaders headers, @Context UriInfo uriDetails, @Context Request request, @Context HttpServletRequest requestContext) throws SecurityException, IOException
{
UpdateInformation updateinformation = new UpdateInformation();
log.info("Method -- " + request.getMethod());
log.info("Complete URI -- "+ uriDetails.getRequestUri().toString());
log.info("Content Type -- "+ requestContext.getContentType());
// log.info("Body -- "+ requestContext.getReader().lines());
...
...
return updateinformation;
}
創建一個ClientInformation POJO並使用JAXB對其進行註釋。然後你可以直接訪問你的beschaffeUpdateInformation方法中的clientInformation。這個方法也應該返回UpdateInformation的一個實例。 –
我想讀取XML(字符串)並將其寫入文件log.txt – Nadin
ClientInformation的外觀如何? –