수정사항
product_sql.txt
create table product
(
product_code int AUTO_INCREMENT primary key,
product_name varchar(100) not null,
description varchar(2000),
price int default 0,
filename varchar(500),
filesize bigint DEFAULT 0 NOT NULL,
regdate datetime DEFAULT now()
);
comment_sql.txt
create table pcomment
(
cno int AUTO_INCREMENT primary key -- 댓글번호
,
pno int not null -- 부모글 번호
,
content VARCHAR(5000) not null -- 댓글내용
,
wname VARCHAR(100) not null -- 작성자
,
regdate datetime default now() -- 작성일
);
application.properties
#server.port=9095
#주의사항 JSP, Thymeleaf, Mustache는 공통으로 사용할 수 없음
#JSP를 뷰페이지로 사용할 경우 pom.xml에 라이브러리 추가해야 함
spring.mvc.view.prefix=/WEB-INF/views/
spring.mvc.view.suffix=.jsp
#JSP페이지가 수정이 되면 자동으로 서버 재시작
server.servlet.jsp.init-parameters.development = true
#파일 업로드 용량 제한 설정
spring.servlet.multipart.max-file-size = 500MB
spring.servlet.multipart.max-request-size = 500MB
#cafe24서버 MariaDB연결
spring.datasource.driverClassName=org.mariadb.jdbc.Driver
spring.datasource.url=jdbc:mariadb://localhost:3306/아이디
spring.datasource.username=아이디
spring.datasource.password=비밀번호
pom.xml
<!-- Maria DB 의존성 추가 -->
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>3.0.6</version>
</dependency>
기존에는 <version>3.0.6</version> 대신 <scope>runtime</scope>를 사용했는데 호스팅 시 문자열(한, 영 모두)이 깨지는 현상이 나타났다. 최신 버전을 사용하면 이러한 현상이 없다고 해서 변경
product.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- product.xml -->
<mapper namespace="product">
<select id="list" resultType="java.util.Map">
SELECT product_code, product_name, description, price, filename
FROM product
ORDER BY product_name
</select>
<insert id="insert" parameterType="java.util.Map">
INSERT INTO product(product_name, description, price, filename, filesize)
VALUES (#{product_name}, #{description}, #{price}, #{filename}, #{filesize})
</insert>
<select id="search" resultType="java.util.Map">
SELECT product_code, product_name, description, price, filename
FROM product
WHERE product_name LIKE #{product_name}
ORDER BY product_name
</select>
<select id="detail" resultType="java.util.Map">
SELECT product_code, product_name, description, price, filename, filesize, regdate
FROM product
WHERE product_code = #{product_code}
</select>
<update id="update">
UPDATE product
SET product_name=#{product_name}
,price=#{price}
,description=#{description}
,filename=#{filename}
WHERE product_code=#{product_code}
</update>
<select id="filename" resultType="String">
SELECT filename
FROM product
WHERE product_code=#{product_code}
</select>
<delete id="delete">
DELETE FROM product
WHERE product_code=#{product_code}
</delete>
</mapper>
comment.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="comment">
<insert id="insert" parameterType="kr.co.itwill.comment.CommentDTO">
INSERT INTO pcomment(pno, content, wname)
VALUES (#{pno}, #{content}, #{wname})
</insert>
<select id="list" resultType="kr.co.itwill.comment.CommentDTO" parameterType="int">
SELECT cno, pno, content, wname, regdate
FROM pcomment
WHERE pno=#{pno}
</select>
<delete id="delete" parameterType="int">
DELETE FROM pcomment
WHERE cno=#{cno}
</delete>
<insert id="update" parameterType="kr.co.itwill.comment.CommentDTO">
UPDATE pcomment
SET content=#{content}
WHERE cno=#{cno}
</insert>
</mapper>
jsp 파일
빨간 밑줄 부분은 원래 대문자로 썼지만 호스팅 할 때 칼럼명을 소문자로 했기 때문에 변경해주었다.
ProductCont.java
insert와 update에서 "\\"를 "/"로 수정했다.
"\\"로 했을 때 storage 폴더 내에 사진이 저장되지 않고 그 밖에 저장되었기 때문이다.
update에서 이 부분 역시 소문자로 변경해주었다.
Properties에서 1.8버전으로 변경
프로젝트 우클릭 후 war 생성
파일명을 ROOT.war로 변경 후 서버에 업로드. 위치는 webapps 아래
자동으로 압축이 풀리며 폴더들이 알아서 자리를 찾아 위치한다.
위 폴더에서 tomcat 관련 jar 삭제
'웹개발 교육 > Spring' 카테고리의 다른 글
[77일] Spring (25) - MyBatis 프로젝트 (댓글 게시판-목록, 삭제, 수정) (0) | 2022.11.15 |
---|---|
[76일] Spring (24) - MyBatis 프로젝트 (댓글 게시판) (0) | 2022.11.14 |
[75일] Spring (23) - MyBatis 프로젝트 (삭제) (0) | 2022.11.11 |
[75일] Spring (22) - MyBatis 프로젝트 (수정) (0) | 2022.11.11 |
[75일] Spring (21) - MyBatis 프로젝트 (상세보기) (0) | 2022.11.11 |