jersey 打印原始数据

好久没有整理最近遇到的问题了,先更新个,慢慢补。

 

jersey 1.13

 

用jersey实现restful web service,而,如果用jersey的自动装载的话,如何将调用端的原始数据打印出来?

 

刚开始的时候想写一个自定义的filter,将原始数据打印出来,但是,post上来的普通数据,调用request.getInputStream() 获取以后,request中的流就已经被取出来了,后面jersey再取的时候就会报错,见http://shootyou.iteye.com/blog/1337199,所以不可行。

 

于是google之 ,发现jersey有实现此功能的filter,配置一下就可以了。

 

比如我的web.xml配置完之后就是这样的:

 


  
    contextConfigLocation
    classpath*:applicationContext.xml
  
  
    org.springframework.web.context.ContextLoaderListener
  
  
  	JAX-RS REST Servlet
  	JAX-RS REST Servlet
  	
  		com.sun.jersey.spi.spring.container.servlet.SpringServlet
  	
  	
		com.sun.jersey.config.property.packages
		com.path.resource
	
  	
		com.sun.jersey.api.json.POJOMappingFeature
		true
	
	
         com.sun.jersey.spi.container.ContainerRequestFilters
         com.sun.jersey.api.container.filter.LoggingFilter
     
     
         com.sun.jersey.spi.container.ContainerResponseFilters
         com.sun.jersey.api.container.filter.LoggingFilter
     
  	1
  
  
  	JAX-RS REST Servlet
  	/rest/*
  
  
  
    index.jsp
  
 

你可能感兴趣的:(java,json)