java请求头Headers添加其他参数

Posted java李杨勇

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java请求头Headers添加其他参数相关的知识,希望对你有一定的参考价值。

package com.railway.core.utils;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebFilter("/*")
public class CORSFilter implements Filter 
    public CORSFilter() 
    
    public void destroy() 
    
    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException 
        //设置跨域请求
        HttpServletResponse response = (HttpServletResponse) res;
            response.setHeader("Access-Control-Allow-Origin", "*");
            response.setHeader("Access-Control-Allow-Methods", "POST,GET,OPTIONS,DELETE,HEAD,PUT,PATCH");
            response.setHeader("Access-Control-Max-Age", "36000");
            response.setHeader("Access-Control-Allow-Headers", "lineId,Origin, X-Requested-With, Content-Type, Accept,Authorization,authorization");
            response.setHeader("Access-Control-Allow-Credentials","true");
        chain.doFilter(req, response);
    
    public void init(FilterConfig fConfig) throws ServletException 
    

以上是关于java请求头Headers添加其他参数的主要内容,如果未能解决你的问题,请参考以下文章

java请求头Headers添加其他参数

python headers请求头快速添加

selenium 怎样设置请求头

selenium 怎样设置请求头

vue interceptors 设置请求头

修改浏览器请求头插件Modify Headers