Example usage for org.springframework.http HttpHeaders ACCESS_CONTROL_ALLOW_ORIGIN

List of usage examples for org.springframework.http HttpHeaders ACCESS_CONTROL_ALLOW_ORIGIN

Introduction

In this page you can find the example usage for org.springframework.http HttpHeaders ACCESS_CONTROL_ALLOW_ORIGIN.

Prototype

String ACCESS_CONTROL_ALLOW_ORIGIN

To view the source code for org.springframework.http HttpHeaders ACCESS_CONTROL_ALLOW_ORIGIN.

Click Source Link

Document

The CORS Access-Control-Allow-Origin response header field name.

Usage

From source file:nl.dtls.fairdatapoint.api.config.ApplicationFilter.java

@Override
public void doFilter(ServletRequest sr, ServletResponse sr1, FilterChain fc)
        throws IOException, ServletException {
    HttpServletResponse response = (HttpServletResponse) sr1;
    HttpServletRequest request = (HttpServletRequest) sr;
    response.setHeader(HttpHeaders.SERVER, "FAIR data point (JAVA)");
    response.setHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, "*");
    response.setHeader(HttpHeaders.ALLOW, (RequestMethod.GET.name()));
    response.setHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS, (HttpHeaders.ACCEPT));
    ThreadContext.put("ipAddress", request.getRemoteAddr());
    ThreadContext.put("responseStatus", String.valueOf(response.getStatus()));
    fc.doFilter(sr, sr1);/*from   w  ww . j a  va  2 s  .  c o m*/
    ThreadContext.clearAll();
}