0
我想将CacheControl信息添加到使用json绑定的GET服务。 我发现到cacheControl添加到响应REST服务的声音是这样的:使用Jersey和json实现的HTTP CacheControl
@GET
@Path("cacheheadertest")
@Produces({"*/*"})
def testcache():javax.ws.rs.core.Response {
val rb:Response.ResponseBuilder = javax.ws.rs.core.Response.ok("chached test message")
val cc = new CacheControl()
cc.setMaxAge(60)
cc.setNoCache(false)
rb.cacheControl(cc).build()
}
,但我有一个产生JSON消息的REST服务和球衣库从Java转换automaticcally的Java对象到XML/JSON 。
@GET
@Path("jsontestcache")
@Produces(Array(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML))
def myjsontestservice(@HeaderParam("X-TOKENID") tokenId: String,
@QueryParam("clientId") clientId: String):com.test.MyResultClass = {
val response= new com.test.MyResultClass
[...]
response
}
如何将缓存控件添加到myjsontestservice服务的响应中?我需要使用过滤器并在球衣创建响应后追加缓存控制吗? thanks million Flavio