httpservletrequest in spring boot

Solutions on MaxInterview for httpservletrequest in spring boot by the best coders in the world

showing results for - "httpservletrequest in spring boot"
Fabio
21 Jan 2017
1package com.onclickinfo.tnoadmin;
2
3import java.io.IOException;
4import javax.servlet.Filter;
5import javax.servlet.FilterChain;
6import javax.servlet.FilterConfig;
7import javax.servlet.ServletException;
8import javax.servlet.ServletRequest;
9import javax.servlet.ServletResponse;
10import javax.servlet.http.HttpServletRequest;
11import javax.servlet.http.HttpServletResponse;
12import org.slf4j.Logger;
13import org.slf4j.LoggerFactory;
14import org.springframework.stereotype.Component;
15
16@Component
17public class SimpleCORSFilter implements Filter {
18
19	private final Logger log = LoggerFactory.getLogger(SimpleCORSFilter.class);
20
21	public SimpleCORSFilter() {
22		log.info("SimpleCORSFilter initiliazed!");
23	}
24
25	@Override
26	public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
27		log.info("SimpleCORSFilter doFilter START ");
28		HttpServletRequest request = (HttpServletRequest) req;
29		HttpServletResponse response = (HttpServletResponse) res;
30
31		response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
32		response.setHeader("Access-Control-Allow-Credentials", "true");
33		response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
34		response.setHeader("Access-Control-Max-Age", "3600");
35		response.setHeader("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With, remember-me");
36
37		chain.doFilter(req, res);
38		log.info("SimpleCORSFilter doFilter END");
39	}
40
41	/*
42	@Override
43	public void init(FilterConfig filterConfig) {
44	}
45
46	@Override
47	public void destroy() {
48	}
49	*/
50
51}
52
queries leading to this page
spring get httpservletrequest in controllerwhat is httpservletrequest in spring bootget httpservletrequest in spring boot controllerhttpservletrequest example spring bootuse httpservletrequest in boothttp servlet request spring frameworkhttpservletrequest in spring controllerhttpservletrequest data springhttpservletrequest springhttpservletrequest java spring bootspring boot http servlet requesthttpservletrequest request spring bootwhy use httpservlet request springbootwhy use httpservletrequest spring bootservlet request to httpservletrequest spring bootspring map httpservletrequestspring boot work with httpservletrequestspringboot httpservletrequest why using spring boothttpservletrequest request in spring controllerspring mvc httprequestservletspring http servlet requesthttpservletrequest spring boottomcat manager start does not workhttp servlet request spring bootspringboot controller httpservletrequesttomcat manager app not workinghow to have spring httpservletrequest to another apispring httpservletrequestspring servlet to httpservlet requestcreate httpsrvletrequest object in spring boothow to get httpservletrequest in spring boothttpservletrequestwrapper spring bootget httpservletrequest spring boothttpservletrequest spring boot controllerusing httpservletrequest in spring examplehttpservletrequest springusing httpservletrequest in springhttpservletrequest in spring bootgetting httpservletrequest in spring controller httpservletrequest why using spring bootspring boot httpservletrequest for rest apihow to create httpservletrequest object in springhttpservletrequest in spring boot controllerspring boot servletrequestspring boot get httpservletrequestspring boot httpservletrequest 3fspring boot add httpservletrequesthttpservletrequest in spring boot