Java/Spring Boot(70)
-
Spring boot 정적 파일 위치 셋팅
기본 위치/resources/static/resources/public설정 변경spring: mvc: static-path-pattern: /** web: resources: static-locations: "classpath:/static/"
2024.08.11 -
Spring boot access log 설정
Log 생성 위치Local: {프로젝트 Dir}/logsServer: {jar 파일이 있는 Dir}/logs설정application.yml에 적용server: tomcat: basedir: . accesslog: enabled: true pattern: '%{yyyy-MM-dd HH:mm:ss}t %s %r %{User-Agent}i %{Referer}i %a %b'
2024.08.11 -
객체를 json으로 변환해서 보내기
# data.put에 들어가는 값이 null이면, json 결과에서 제외 됨# targetUrl = null이면, response에 referer가 빠짐response.setContentType("application/json;charset=UTF-8");response.setStatus(HttpServletResponse.SC_OK);JSONObject data = new JSONObject();data.put("success", true);data.put("msg", "테스트 성공!!");data.put("referer", targetUrl);PrintWriter writer = response.getWriter();writer.print(data);writer.flush();
2024.08.03 -
because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
response 결과가 '302'로 나옴css 파일이 존재하지만, Spring boot Security에서 로그인 예외처리를 하지 않아서 접근이 안되는 문제환경설정에서 예외 처리를 해줘야 함@Configuration@EnableWebSecuritypublic class WebSecurityConfig { @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { http.authorizeHttpRequests((requests) -> requests .requestMatchers("/", "{css 디렉토리}/*.css").permitAll() .anyRequest().authenticat..
2024.07.18 -
Spring boot에 sencha app 생성
spring boot project에 static 디렉토리 생성sencha app 생성# workspace 생성cd {sprinb boot project directory}/src/main/resources/staticsencha generate workspace .# app 생성sencha -sdk {sencha directory} generate app {sencha proejct name}spring boot project에서 static 디렉토리 refresh확인localhost:{port}/index.html
2024.07.13 -
ViewController 추가
ViewController만 일괄로 추가할때 유용할 것 같음@Configurationpublic class WebMvcConfig implements WebMvcConfigurer {public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/home").setViewName("home"); registry.addViewController("/").setViewName("home"); registry.addViewController("/hello").setViewName("hello"); registry.addViewController("/login").setViewName("login")..
2024.06.13