Vue.js 에서 히스토리 모드를 사용하기 위해 Spring Boot 단에서 모든 url을 index로 보내는 설정을 해주었으나..

로컬에서 돌렸을 때는 잘 되는데 서버 Tomcat에 올리니 안 되는 현상 발생.

아예 Tomcat 단에서 url을 /로 보내도록 rewrite 설정을 해주었다.



1. 톰캣(ver.9) 폴더 / conf / server.xml - <context> 밑에 valve 추가.


<Context path="" docBase="프로젝트 폴더\src\main\resources\static" reloadable="true">

<Valve className="org.apache.catalina.valves.rewrite.RewriteValve"/>

</Context>


2. 프로젝트 Root 폴더 안에 /WEB-INF/rewrite.config 추가


<rewrite.config>

RewriteCond %{REQUEST_URI} ..(.)$ [OR]

RewriteCond %{REQUEST_URI} ^(.)(/api/).$ [OR]
RewriteRule ^(.*)$ - [L]

RewriteRule ^(.*)$ /index.html



이러니 잘 됨. 끝~

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.util.Scanner;
 
public class BOJ_1182 {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        int result = sc.nextInt();
        int[] arr = new int[n];
        int bitMax = (int) (Math.pow(2, n) - 1);
        int cnt = 0;
 
        for (int i = 0; i < n; i++) { // Initialization
            arr[i] = sc.nextInt();
        }
 
        for (int bit = 1; bit <= bitMax; bit++) { // 모든 비트 순회
            int sum = 0;
 
            for (int i = 0; i < n; i++) { // 1인 비트 체크
                if ((bit & (1 << i)) != 0)
                    sum += arr[i];
            }
 
            if (sum == result)
                cnt++;
        }
 
        System.out.println(cnt);
 
    }
 
}
 
cs

'공부 > 알고리즘문제' 카테고리의 다른 글

백준 16234 인구 이동  (0) 2019.04.08
백준 14503 로봇 청소기  (0) 2017.05.01
백준 14500 테트로미노  (0) 2017.04.24
백준 7562 나이트의 이동  (0) 2017.04.15
백준 2178 미로 탐색  (0) 2017.04.15

Spring boot - Vue.js 연동 기준


라우터에 history mode 옵션을 주면 메인을 제외하고는 없는 페이지라고 떴다.




@RequestMapping(value = "{path:[^\\\\.]*}",

method = {RequestMethod.POST, RequestMethod.GET})

public String html5Forwarding() {

return "forward:/index.html";

}




Path value를 저렇게 주면 vue.js url로 잘 넘어감..

아직까진 잘 되는데 문제 생기면 포스팅 수정하는걸로..