hyeonga_code

reProject_01_프로젝트 재정비 본문

Project_WEATHERWEAR

reProject_01_프로젝트 재정비

hyeonga 2023. 12. 12. 05:59
반응형

 

2023-12-08

    - 프로젝트 기간이 종료되었지만 프로젝트가 완벽하지 않은 상태로 마무리되었으므로 다시 보완하기로 결정

    - 부족한 점

        - 화면이 일관성 없이 각자 진행하여 충돌하는 css

        - 일관되지 않은 코딩으로 코딩의 호환률이 좋지 않음

        - 서로의 코딩에 유사한 부분이나 재사용이 가능한 부분들을 사용할 수 없고 기능을 추가할 때마다 새로 작성해야 함

2023-12-09 ~ 2023-12-10

    - 화면부터 완벽하게 나온 상태로 진행해야 무리없이 가능한 것 같아 미리 화면부터 작업하기로 함

    - 페이지들의 일관성이 없어 와이어프레임을 작성

사용자 페이지 관리자 페이지  
        - 메인
        - 로그인
        - 정보 찾기 (아이디/비밀번호)
        - 회원 가입 
        - 상품 리스트 
        - 상품 상세 
        - 장바구니 
        - 주문
        - 주문 완료
        - 주문 상세
        - 교환/환불 요청
        - 마이페이지
        - 로그인
        - 메인
        - 상품 관리
        - 주문 관리
        - 상품 등록/수정
        - 회원 관리
        - 공지 관리
        - 문의 관리

 

2023-12-11

- 기존에 작업하던 프로젝트를 보완할 것이므로 기본 설정은 가지고 올것

1. 프로젝트 생성하기

New > Spring Legacy Project

-- project name : teamProject_weatherwear

-- package: com.w2.w2 ( 마지막 정보가 톰캣 서버의 기본 주소로 저장됩니다.)

> Finish

 

2. 프로젝트 우클릭 > Properties > Project Facets

-- java 버전 11로 변경

-- runtime 톰캣 체크 

> Apply and Close

 

3. pom.xml 파일에 라이브러리 추가

-- properties > java 버전 변경

-- servlet-api > javax.servlet-api 변경

-- jsp-api > javax.servlet.jsp-api 변경

-- jnuit 버전 변경

-- 기존 기능을 모두 사용할 것이므로 기존의 프로젝트에서 모두 가져옵니다.

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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.w2</groupId>
    <artifactId>w2</artifactId>
    <name>teamProject_weatherwear</name>
    <packaging>war</packaging>
    <version>1.0.0-BUILD-SNAPSHOT</version>
    <properties>
        <java-version>11</java-version>
        <org.springframework-version>5.3.27</org.springframework-version>
        <org.aspectj-version>1.9.19</org.aspectj-version>
        <org.slf4j-version>2.0.7</org.slf4j-version>
    </properties>
    <dependencies>
<!-- 기본 설정 파일 시작 -->
<!-- Spring-context -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${org.springframework-version}</version>
            <exclusions>
                <!-- Exclude Commons Logging in favor of SLF4j -->
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
<!-- spring-webmvc -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>
 
<!-- Aspectrt -->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>${org.aspectj-version}</version>
        </dependency>
 
    <!-- Logging -->
<!-- slf4j-api -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${org.slf4j-version}</version>
        </dependency>
<!-- jcl-over-slf4j -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>${org.slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>
<!-- slf4j-version -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${org.slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>
<!-- log4j -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.15</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.mail</groupId>
                    <artifactId>mail</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.jms</groupId>
                    <artifactId>jms</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jdmk</groupId>
                    <artifactId>jmxtools</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jmx</groupId>
                    <artifactId>jmxri</artifactId>
                </exclusion>
            </exclusions>
            <scope>runtime</scope>
        </dependency>
 
        <!-- @Inject -->
<!-- javax.inject -->
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>
 
    <!-- Servlet -->
<!-- javax.servlet-api -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>4.0.0</version>
            <scope>provided</scope>
        </dependency>
<!-- javax.servlet.jsp-api -->
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>javax.servlet.jsp-api</artifactId>
            <version>2.3.3</version>
            <scope>provided</scope>
        </dependency>
<!-- jstl -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
 
        <!-- Test -->
<!-- junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>
    <!-- 기본 설정 파일 끝 -->
    
    <!-- Mybatis 연동 시작 -->
<!-- mybatis -->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.5.13</version>
        </dependency>
<!-- mybatis-spring -->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>2.1.0</version>
        </dependency>
    <!-- Mybatis 연동 끝 -->
    
    <!-- AWS RDS : 연동 시작 -->
<!-- mysql-connector-java : MySQL 연결 라이브러리 -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.33</version>
        </dependency>
 
<!-- spring-jdbc : 데이터베이스와 연결하는 라이브러리 -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>    
    <!-- AWS RDS : 연동 끝 -->
    
<!-- commos-dbcp2 -->
        <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-dbcp2</artifactId>
                <version>2.10.0</version>
        </dependency>    
 
<!-- 파일 업로드 라이브러리 시작 -->
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.5</version>
        </dependency>
        
        <!-- commons-io -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
        </dependency>
<!-- 파일 업로드 라이브러리 끝 -->
 
<!-- lombok -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.22</version>
            <scope>provided</scope>
        </dependency>
 
<!-- json-simple : JSON 작업을 위해 필요한 라이브러리 시작 -->
        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1.1</version>
        </dependency>
<!-- json-simple : JSON 작업을 위해 필요한 라이브러리 끝 -->
 
<!-- Email 인증번호 발급 적용 시작 -->
        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-email -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-email</artifactId>
            <version>1.5</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/javax.mail/mail -->
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.7</version>
        </dependency>
        
        <!-- https://mvnrepository.com/artifact/com.google.apis/google-api-services-gmail -->
        <dependency>
            <groupId>com.google.apis</groupId>
            <artifactId>google-api-services-gmail</artifactId>
            <version>v1-rev110-1.25.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.google.oauth-client/google-oauth-client-jetty -->
        <dependency>
            <groupId>com.google.oauth-client</groupId>
            <artifactId>google-oauth-client-jetty</artifactId>
            <version>1.34.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.google.http-client/google-http-client-jackson2 -->
        <dependency>
            <groupId>com.google.http-client</groupId>
            <artifactId>google-http-client-jackson2</artifactId>
            <version>1.42.3</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.google.http-client/google-http-client -->
        <dependency>
            <groupId>com.google.http-client</groupId>
            <artifactId>google-http-client</artifactId>
            <version>1.43.3</version>
        </dependency>
<!-- Email 인증번호 발급 적용 끝 -->
 
<!-- AWS S3에 파일 업로드 라이브러리 시작 -->
        <!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-s3 -->
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-s3</artifactId>
            <version>1.12.464</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.15.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-xml -->
        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-xml</artifactId>
            <version>2.15.1</version>
        </dependency>
<!-- AWS S3에 파일 업로드 라이브러리 끝 -->
 
<!-- 암호화 라이브러리 시작 5.7.5-->
        <!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-core -->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>5.7.5</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-web -->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>5.7.5</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-config -->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>5.7.5</version>
        </dependency>
<!-- 암호화 라이브러리 끝 -->
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <additionalProjectnatures>
                        <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                    </additionalProjectnatures>
                    <additionalBuildcommands>
                        <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                    </additionalBuildcommands>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.10.1</version>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                    <compilerArgument>-Xlint:all</compilerArgument>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <mainClass>org.test.int1.Main</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

 

 

4. context.xml 파일 설정하기

- web.xml

    - 설정을 위한 설정파일

    - 최초로 서버가 실행될 때 설정을 정의

    - XML 파일들을 인식

- root-context.xml

    - view와 관련되지 않은 객체를 정의

    - service, repository, db 등 비즈니스 로직과 관련된 설정을 작업합니다.

    - 백엔드 설정파일입니다.

    - 모든 context.xml 파일에서 사용할 수 있음

    - service, dao 등 웹 환경에 독립적인 빈을 담아둔다

    - servlet-context 내의 빈은 사용할 수 없음

- servlet-context.xml

    - 요청과 관련된 객체를 정의

    - url과 관련된 컨트롤러, 어노테이션, 뷰 리졸버 등의 설정

    - 프론트엔드 설정 파일

    - 해당 컨텍스트에서만 사용할 수 있음

    - root-context.xml 파일의 빈을 사용할 수 있음

 

1) web.xml 파일 수정하기

- Encofing Filter 등록

<!-- 인코딩 설정 시작-->
	<filter>
		<filter-name>encodingFilter</filter-name>
		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>UTF-8</param-value>
		</init-param>
		<!-- Encofing 강제 -->
		<init-param>
			<param-name>forceEncoding</param-name>
			<param-value>true</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>encodingFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

 

- 스프링 기본 설정 파일을 위한 context, listener 등록

<!-- root-context 설정 -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>
			/WEB-INF/spring/applicationContext.xml
			<!-- 기본 설정 컨텍스트 파일 위치 -->
		</param-value>
	</context-param>
    
	<!-- contextConfigLocation에 있는 root-context를 불러옵니다. -->
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

 

- 쇼핑몰의 사용자/관리자의 진입 경로 구분을 위해 따로 DispatcherServlet 구분

   > 사용자 설정 : "*.do"로 접근

	<!-- 사용자 설정 -->
	<servlet>
		<servlet-name>client</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>
				/WEB-INF/config/client-context.xml
				<!-- 사용자 관련 설정 파일 위치 -->
			</param-value>
		</init-param>
	</servlet>
	<servlet-mapping>
		<servlet-name>client</servlet-name>
		<url-pattern>*.do</url-pattern>
	</servlet-mapping>

 

   > 관리자 설정 : "*.mdo"로 접근

	<!-- 관리자 설정 -->
	<servlet>
		<servlet-name>admin</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>
				/WEB-INF/config/admin-context.xml
				<!-- 관리자 관련 설정 파일 위치 -->
			</param-value>
		</init-param>
	</servlet>
	<servlet-mapping>
		<servlet-name>admin</servlet-name>
		<url-pattern>*.mdo</url-pattern>
	</servlet-mapping>

 

 

전체

 

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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee https://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
 
    <!-- root-context 설정 -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/spring/applicationContext.xml
            <!-- 기본 설정 컨텍스트 파일 위치 -->
        </param-value>
    </context-param>
    
    <!-- contextConfigLocation에 있는 root-context를 불러옵니다. -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
 
    <!-- 사용자 설정 -->
    <servlet>
        <servlet-name>client</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
                /WEB-INF/config/client-context.xml
                <!-- 사용자 관련 설정 파일 위치 -->
            </param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>client</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>
 
    <!-- 관리자 설정 -->
    <servlet>
        <servlet-name>admin</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
                /WEB-INF/config/admin-context.xml
                <!-- 관리자 관련 설정 파일 위치 -->
            </param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>admin</servlet-name>
        <url-pattern>*.mdo</url-pattern>
    </servlet-mapping>
 
    <!-- 인코딩 설정 시작-->
    <filter>
        <filter-name>encodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <!-- Encofing 강제 -->
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>
 

 

 

2) applicationContext.xml

- 공통으로 사용할 설정 파일 (하위 설정 파일들이 상속 받아 사용합니다.)

/WEB-INF/spring/ 경로에 'Spring Bean Configuration File' 생성 > applicationContext.xml

- Namespaces 설정

    - aop

    - beans

    - c

    - context

    - jdbc

    - mybatis

    - p

    - tx

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
36
37
38
39
40
41
42
43
44
45
46
47
48
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:c="http://www.springframework.org/schema/c"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jdbc="http://www.springframework.org/schema/jdbc"
    xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.3.xsd
        http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring-1.2.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
    
<!-- 암호화 -->
    <bean id="bcryptPasswordEncoder" class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder"/>    
    
<!-- SqlSessionTemplate을 사용하여 DAO 클래스 구현 -->
        <!-- setter 메소드가 없으므로 생성자 인젝션을 사용해야 합니다. -->
    <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
        <constructor-arg ref="sqlSessionFactory"/>
    </bean>
 
<!-- MyBatis 연동 : 추가한 라이브러리에서 가져오는 SqlSessionFactoryBean -->    
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="configLocation" value="classpath:mybatis-config.xml" />
    </bean>
 
<!-- Data Source -->
    <!-- 데이터베이스 정보 -->
    <context:property-placeholder location="classpath:config/webserverdb.properties" />
    
    <!--  <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"> -->
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${jdbc.driverClassName}" />
        <property name="url" value="${jdbc.url}" />
        <property name="username" value="${jdbc.username}" />
        <property name="password" value="${jdbc.password}" />
    </bean>
 
<!-- Transaction 관리자 설정 -->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" p:dataSource-ref="dataSource" />
</beans>
 

 

 

3) /WEB-INF/config/ 폴더에 client-servlet.xml, admin-xervlet.xml 파일 생성

- client-servlet.xml  (views/client/ 기본 설정 경로)

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
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:c="http://www.springframework.org/schema/c"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
 
    <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
    <!-- 의존성 주입을 위해 빈 등록 대신 -->
    <context:component-scan base-package="com.w2.client" />
    
    <!-- Annotation을 활용할 때 기본적인 Default 방식을 설정 -->
    <annotation-driven />
 
    <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
    <resources mapping="/resources/**" location="/resources/" />
 
    <!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
    <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/WEB-INF/views/client/" />
        <beans:property name="suffix" value=".jsp" />
    </beans:bean>
    
</beans:beans>
 

 

- admin-servlet.xml (views/admin/ 기본 설정 경로)

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
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:c="http://www.springframework.org/schema/c"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
 
    <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
    <context:component-scan base-package="com.w2.admin" />
    
    <!-- Annotation을 활용할 때 기본적인 Default 방식을 설정 -->
    <annotation-driven />
 
    <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
    <resources mapping="/resources/**" location="/resources/" />
 
    <!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
    <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/WEB-INF/views/admin/" />
        <beans:property name="suffix" value=".jsp" />
    </beans:bean>
    
</beans:beans>

 

4) DB 정보 연결

- applicationContext.xml 파일에 직접 작성하는 경우 보안상의 문제가 발생할 수 있으므로 따로 properties 파일을 생성하여 적용하는 방식을 사용한다.

src/main/resources > config 폴더 생성 > webserverdb.properties 파일 생성

1
2
3
4
jdbc.driverClassName=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://'AWS 서버 RDS 엔드포인트':'RDS 포트'/'사용할 데이터베이스 이름'
jdbc.username='데이터베이스 계정 아이디'
jdbc.password='데이터베이스 계정 비밀번호'

 

5) mybatis-config.xml 파일 생성

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?xml version="1.0" encoding="UTF-8"?>
 
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" 
                "http://mybatis.org/dtd/mybatis-3-config.dtd">
 
<configuration>
    
    <typeAliases>
        <!-- typeAlias
                - 매핑파일에서 사용하는 type을 지정
                - 애플리케이션에서 SQL 문으로 값을 전달합니다
                - SQL 문 실행 시 반환되는 레코드를 저장하는 용도로 사용하기 위한 빈을 생성합니다.-->
    </typeAliases>
 
    <!-- SQL 작성문을 지정하여 mapper 파일 경로 알려주는 역할입니다. -->
    <mappers>
        
    </mappers>
</configuration>

 

5. header.jspf, footer.jspf 파일 생성하기

-- webapp/WEB-INF/views/client/base/ 폴더에 client_header.jspf 파일 생성

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
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<header class="header clear">
    <img src='/w2/resources/client/client_image/logo_pull.png' class="header_img">
    <!-- 익명의 사용자 -->
    <nav class="user_menu">
        <ul>
            <li><a href="#">LOGIN</a></li>
            <li><a href="#">JOIN</a></li>
            <li><a href="#">CART</a></li>
        </ul>
    </nav>
    
    <!-- 로그인한 사용자 -->
    <nav class="user_menu">
        <ul>
            <li><a href="#">CART</a></li>
            <li><a href="#">MYPAGE</a></li>
            <li><a href="#">LOGOUT</a></li>
        </ul>
    </nav>
    <div class="clear_con"></div>
    <nav class="main_menu">
        <ul>
            <li><a class="main_menu_a" href="#"><strong>ALL</strong></a></li>                
            <li><a class="main_menu_a" href="#"><strong>OUTER</strong></a></li>                
            <li><a class="main_menu_a" href="#"><strong>TOP</strong></a></li>                
            <li><a class="main_menu_a" href="#"><strong>PANTS</strong></a></li>                
            <li><a class="main_menu_a" href="#"><strong>SKIRTS</strong></a></li>                
            <li><a class="main_menu_a" href="#"><strong>DRESS</strong></a></li>                
            <li><a class="main_menu_a" href="#"><strong>COMMUNITY</strong></a></li> 
        </ul>
    </nav>
</header>

 

-- webapp/WEB-INF/views/client/base/ 폴더에 client_footer.jspf 파일 생성

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<div class="footer">
    <nav class="footer_menu">
        <ul>
            <li><a class="footer_menu_a" href="#">NOTICE</a></li>
            <li><a class="footer_menu_a" href="#">EVENT</a></li>
            <li><a class="footer_menu_a" href="#">REVIEW</a></li>
            <li><a class="footer_menu_a" href="#">TERMS</a></li>
            <li><a class="footer_menu_a" href="#">POLICY</a></li>
        </ul>
    </nav>
    <span class="footer_logo">WEATHERWEAR</span>
    <div class="clear_con"></div>
    <dl class="footer_info">
        <dd>OWNER : 김 희 진</dd>
        <dd>ADDRESS : 서울시 종로구</dd>
        <dd>NUMBER : 010-1212-8989</dd>
        <dd>PERMIT NUMBER: 123-12-12345</dd>
        <dd>BANK ACCOUNT : SHINHAN 111-111-111111 주) weatherwear</dd>
    </dl>
</div>

 

-- webapp/WEB-INF/views/client/ 폴더에 client_main.jspf 파일 생성

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>WEATHERWEAR</title>
    <link rel="stylesheet" href="/w2/resources/client/client_css/client_main_style.css">
</head>
<body>
    <div class="container">
        <%@ include file="/WEB-INF/views/client/base/client_header.jspf" %>
        <div class="body">
            
        </div>
        <%@ include file="/WEB-INF/views/client/base/client_footer.jspf" %>
    </div>
</body>
</html>

 

-- webapp/resources/client/client_css/ 폴더에 client_main_style.css 파일 생성

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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
@charset "UTF-8";
 
{
    font-family: fangsong;
}
 
.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
}
 
/* float 정리 : 하위 태그들만 적용됩니다. */
.clear:after {
    content:'';
    display: block;
    clear: both;
}
 
.clear_con {
    content: '';
    diplay: block;
    clear: both;
}
 
/* 헤더 */
.header {
    box-sizing: border-box;
    width: 95%;
    height:25%;
    margin: 10px;
    padding:10px;
    border: 2px dotted grey;
    
    max-width: 3600px; 
    max-height: 100%;
    
    min-width: 600px;
    min-height: auto;
}
 
/* 헤더: 로고 */
.header_img{
    float:left;
    width: 250px;
    height: auto;
    padding: 20px;
    
    max-width: 300px;
    min-width: 200px;
    max-height: auto;
    min-height: auto;
}    
 
/* 헤더: 사용자 메뉴 */
.user_menu{
    float: right;
}
 
.user_menu > ul {
    list-style: none;
    display: inline-block;
}
 
.user_menu > ul > li {
    display: inline;
    margin: 5px;
}
 
.user_menu > ul > li > a{
    text-decoration: none;
    color: grey;
}
 
/* 헤더: 매인 메뉴 */
.main_menu {
    display: flex;
    justify-content: center;
    border-bottom: 3px solid dimgrey;
}
 
.main_menu > ul {
    list-style: none;
    display: flex;
    padding-left: 0;
    width: 98%;
}
 
.main_menu > ul > li {
    display: inline;
    margin: 5px auto;
    text-align: center;
}
 
.main_menu > ul > li > a{
    text-decoration: none;
    color: black;
}
 
.main_menu > ul > li > a:hover{
    color: red;
}
 
/* 콘텐츠 고정 크기 */
.body {
    box-sizing: border-box;
    width: 95%;
    height:900px;
    margin: 10px;
    padding:10px;
    border: 2px dotted grey;
    
    max-width: 3600px; 
    max-height: 100%;
    
    min-width: 600px;
    min-height: auto;
}
 
/* footer */
.footer {
    box-sizing: border-box;
    background-color: lightgrey;
    width: 95%;
    height:10%;
    margin: 10px;
    padding:10px;
    border: 2px dotted grey;
    
    max-width: 3600px; 
    max-height: 100%;
    
    min-width: 600px;
    min-height: auto;
}
 
.footer_menu {
    float: right;
}
 
.footer_menu > ul {
    list-style: none;
    display: inline-block;
}
 
.footer_menu > ul > li {
    display: inline;
    margin: 5px;
}
 
.footer_menu > ul > li > a {
    text-decoration: none;
    color: grey;
}
 
.footer_logo {
    font-size: xx-large;
    color: dimgrey;
    padding: 15px;
}
 
.footer_info > dd {
    margin-bottom: 5px;
    color: dimgrey;
}

 

6. 실행을 위해 Controller 생성

src/main/java > com.w2.client 패키지 생성 > ClientController.java 클래스 생성

1
2
3
4
5
6
7
8
9
10
11
12
13
package com.w2.client.controller;
 
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
 
@Controller
public class ClientController {
    
    @RequestMapping("do.do")
    public String sample() {
        return "client_main";
    }
}

 

>>> 서버 실행해보기

'localhost:8080/w2/do.do' 검색

    - 최종적으로  border 모두 삭제할 것

 

 

reProject_02_ input 태그 간단한 css, 로그인 페이지, 아이디 찾기/ 비밀번호 찾기 페이지 구현하기

2023.12.12. input 태그 css 정리 > css 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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 inpu

hyeonga493.tistory.com

 

반응형