깃허브를 이용하기 위한 패키지와 클래스명 정리
recipe
recipe.controller/
RecipeController.java
RecipeCommentController.java
recipe.domain/
Recipe.java
RecipeComment.java
RecipeMaterial.java
RecipeStep.java
RecipeTag.java
Recommandation.java
recipe.service/(인터페이스)
RecipeService.java
RecipeCommentService.java
recipe.service.logic/
RecipeServiceImpl.java
RecipeCommentServiceImpl.java
recipe.store/(인터페이스)
RecipeStore.java
RecipeCommentStore.java
recipe.store.logic/
RecipeStoreLogic.java.java
RecipeCommentStoreLogic.java
qanda
qanda.controller/
QAComemnetController.java
QAController.java
qanda.domain/
QAComment.java
QA.java
qanda.service/(인터페이스)
QACommentService.java
QAService.java
qanda.service.logic/
QAServiceImpl.java
QACommentServiceImpl.java
qanda.store/(인터페이스)
QAStore.java
QACommentStore.java
qanda.service.logic/
QAStoreLogic.java
QACommentStoreLogic.java
Controller클래스와 메소드 일부작성
@RequestMapping(value="/recipe/regist.do", method = RequestMethod.POST)
public ModelAndView registRecipe(
@ModelAttribute Recipe recipe,@ModelAttribute RecipeStep rStep,@ModelAttribute RecipeMaterial rMaterial,@ModelAttribute RecipeTag rTag,
ModelAndView mv,
@RequestParam(value="mainPicture", required = false) MultipartFile mainPic,
@RequestParam(value="recipePicture1", required = false)MultipartFile detailPic1,
@RequestParam(value="recipePicture2", required = false)MultipartFile detailPic2,
@RequestParam(value="recipePicture3", required = false)MultipartFile detailPic3,
@RequestParam(value="recipePicture4", required = false)MultipartFile detailPic4,
@RequestParam(value="recipePicture5", required = false)MultipartFile detailPic5,
@RequestParam(value="recipePicture6", required = false)MultipartFile detailPic6,
@RequestParam(value="recipePicture7", required = false)MultipartFile detailPic7,
@RequestParam(value="recipePicture8", required = false)MultipartFile detailPic8,
@RequestParam(value="recipePicture9", required = false)MultipartFile detailPic9,
@RequestParam(value="recipePicture10", required = false)MultipartFile detailPic10,
HttpSession session) {
int result = rService.registRecipe(recipe);
int result1 = rService.registMaterial(rmList);
int result2 = rService.registStep(rsList);
int result3 = rService.registTag(rTag);
return mv;
}
- regist 코드를 작성하였다.
- 하지만 몇개의 클래스는 값을 한번에 여러개 받는데 List의 값을 자동으로 입력받는건 어떻게 하지? 내일 알아봐야겠다.
글쓰기 폼 작성
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<head>
<title>레시피 등록</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<link rel="stylesheet" href="./css/recipeStyle.css">
</head>
<body>
<form action="/recipe/regist.do" method="post">
<div class="row row-cols-lg-auto container align-items-center">
<div class="form-floating col-lg-4">
<input type="text" class="form-control" id="" name="recipeName" >
<label for="floatingInput">레시피 제목</label>
</div>
<br>
<div class="form-floating col-lg-4">
<input type="text" class="form-control" id="" name="recipeVideo">
<label for="floatingInput">유튜브 링크</label>
</div>
<div class="col-md-3">
<label for="validationCustom04" class="form-label" >카테고리</label>
<select class="form-select" id="" name="recipeCategory" required>
<option selected disabled value="">카테고리 선택</option>
<option value="mael">식사</option>
<option value="relish">술안주</option>
<option value="dessert">간식</option>
<option value="drink">술/음료</option>
</select>
<div class="invalid-feedback">
카테고리를 선택하세요
</div>
<br>
<div class="col-md-8 col-lg-8">
해시태그<br>
<label><input class="form-check-input" type="checkbox" name="jmt" value="true" > JMT</label>
<label><input class="form-check-input" type="checkbox" name="healthy" value="true"> 건강한</label>
<label><input class="form-check-input" type="checkbox" name="goodSpicy" value="true"> 맛있게 매운</label>
<label><input class="form-check-input" type="checkbox" name="soSpicy" value="true"> 아주매운</label>
<label><input class="form-check-input" type="checkbox" name="sweet" value="true"> 달콤한</label>
<label><input class="form-check-input" type="checkbox" name="easy" value="true"> 간편한</label>
<label><input class="form-check-input" type="checkbox" name="party" value="true"> 파티용</label>
<label><input class="form-check-input" type="checkbox" name="full" value="true"> 든든한</label>
</div>
</div>
<br>
<div class="form-floating col-lg-2 align-items-center">
<input type="text" class="form-control" id="" name="recipeTime">
<label for="floatingInput">소요시간</label>
</div>
<div class="row col-lg-4">
<label class="input-file-button" for="input-file" >
대표이미지추가
<img id="output">
</label>
<input type="file" id="input-file" style="display:none"accept="image/*" name="mainPicture" onchange="loadFile(event)"/>
</div>
<div class=" row row-cols-lg-auto col-lg-8">
<div class="form-floating col-lg-8">
<input type="text" class="form-control" id="" maxlength="30" name="recipeInfo">
<label for="floatingInput"> 간단한소개 (30자 미만)</label>
</div>
</div>
<div class="row row-cols-lg-auto col-lg-12">
<div class="form-floating col-lg-3">
<input type="text" class="form-control" id="" maxlength="10" name="material1">
<label for="floatingInput">재료명</label>
</div>
<div class="form-floating col-lg-3">
<input type="text" class="form-control" id="" maxlength="10" name="amount1">
<label for="floatingInput">재료수량</label>
</div>
<div class="form-floating col-lg-3">
<input type="text" class="form-control" id="" maxlength="10" name="material2">
<label for="floatingInput">재료명</label>
</div>
<div class="form-floating col-lg-3">
<input type="text" class="form-control" id="" maxlength="10" name="amount2">
<label for="floatingInput">재료수량</label>
</div>
</div>
<div class="row row-cols-lg-auto col-lg-12 ">
<div class="form-floating col-lg-3">
<input type="text" class="form-control" id="" maxlength="10" name="materia3">
<label for="floatingInput">재료명
</label>
</div>
<div class="form-floating col-lg-3">
<input type="text" class="form-control" id="" maxlength="10" name="amount3">
<label for="floatingInput">재료수량</label>
</div>
<div class="form-floating col-lg-3">
<input type="text" class="form-control" id="" maxlength="10" name="material4">
<label for="floatingInput">재료명</label>
</div>
<div class="form-floating col-lg-3">
<input type="text" class="form-control" id="" maxlength="10" name="amount4">
<label for="floatingInput">재료수량</label>
</div>
</div>
<div class="row row-cols-lg-auto col-lg-12 ">
<div class="form-floating col-lg-3">
<input type="text" class="form-control" id="" maxlength="10" name="material5">
<label for="floatingInput">재료명
</label>
</div>
<div class="form-floating col-lg-3">
<input type="text" class="form-control" id="" maxlength="10" name="amount5">
<label for="floatingInput">재료수량</label>
</div>
<div class="form-floating col-lg-3">
<input type="text" class="form-control" id="" maxlength="10" name="material6">
<label for="floatingInput">재료명
</label>
</div>
<div class="form-floating col-lg-3">
<input type="text" class="form-control" id="" maxlength="10" name="amount6">
<label for="floatingInput">재료수량</label>
</div>
</div>
</div>
<hr>
<div class="row container">
<div class="form-floating col-lg-6">
<input type="text" class="form-control" id="" maxlength="10" name="recipeDescription1">
<label for="floatingInput">레시피 설명</label>
</div>
<div class="row col-lg-6">
<input type="file" name="recipePicture1">
</div>
<div class="form-floating col-lg-6">
<input type="text" class="form-control" id="" maxlength="10" name="recipeDescription2">
<label for="floatingInput">레시피 설명</label>
</div>
<div class="row col-lg-6">
<input type="file" name="recipePicture2">
</div>
<div class="form-floating col-lg-6">
<input type="text" class="form-control" id="" maxlength="10" name="recipeDescription3">
<label for="floatingInput">레시피 설명</label>
</div>
<div class="row col-lg-6">
<input type="file" name="recipePicture3">
</div>
</div>
</form>
</p>
<script>
var loadFile = function(event) {
var output = document.getElementById('output');
output.src = URL.createObjectURL(event.target.files[0]);
output.onload = function() {
URL.revokeObjectURL(output.src)
}
};
</script>
</body>
</html>
- 부트스트랩을 이용하긴했는데 생각처럼 만들어지지 않는다.. 좀 더 연구가 필요한데 시간이 없다.