java 修改 request参数值_HttpServletRequest修改/添加header和cookie参数

  • Post author:
  • Post category:java


packagecom.mobile.web.common;importorg.springframework.web.filter.OncePerRequestFilter;importjavax.servlet.FilterChain;importjavax.servlet.ServletException;importjavax.servlet.http.Cookie;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletRequestWrapper;importjavax.servlet.http.HttpServletResponse;importjava.io.IOException;import java.util.*;/*** 自定义的过滤器,

* Created by Administrator on 2017/6/19 0019.*/

public class ModifyParametersFilter extendsOncePerRequestFilter {

@Overrideprotected voiddoFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)throwsServletException, IOException {//修改cookie

ModifyHttpServletRequestWrapper mParametersWrapper = newModifyHttpServletRequestWrapper(request);

String token= request.getHeader(“token”);if (token != null && !””.equals(token)) {

mPa



版权声明:本文为weixin_31061573原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。