맨인키
42
2022-05-21 13:24:12
1
92

게시판 글쓰기 에러가 납니다 ㅠㅠ


잘되었는데 갑자기 이런 에러가 뜨네요..


package co.dev.web.board;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.oreilly.servlet.MultipartRequest;
import com.oreilly.servlet.multipart.DefaultFileRenamePolicy;

import co.dev.service.BoardService;
import co.dev.vo.BoardVO;
import co.dev.vo.UserVO;
import co.dev.web.Controller;

public class BoardInsertControl implements Controller {

	@Override
	public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");

		
		String saveDir = "img";
		saveDir = request.getServletContext().getRealPath(saveDir);
		System.out.println(saveDir);
		int maxSize = 1024 * 1024 * 10;
		String encoding = "UTF-8";

		MultipartRequest multi = new MultipartRequest(request, saveDir, maxSize, encoding, new DefaultFileRenamePolicy());
		//request.setCharacterEncoding(encoding);

		String title = multi.getParameter("title");
		String content = multi.getParameter("content");
		String img = multi.getFilesystemName("img");
		
		HttpSession session = request.getSession();
		UserVO vo = new UserVO();
		vo = (UserVO) session.getAttribute("user");
				
		String userId = vo.getId(); // 로그인 사용자 ID

		BoardVO board = new BoardVO();
		board.setContent(content);
		board.setTitle(title);
		board.setUser_id(userId);
		board.setImg(img);
		
		BoardService service = new BoardService();
		service.boardInsert(board);
		
		request.getSession().setAttribute("success", "글 작성이 완료되었습니다.");

		// response.sendRedirect("board.do");
		request.getRequestDispatcher("board.do").forward(request, response);

	}

}


이건 입력 컨트롤이고



<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>	
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	
		<h4>글을 작성하는 공간입니다.</h4>	
		<form action="${pageContext.servletContext.contextPath }/boardWrite.do" method="post"  enctype="multipart/form-data">
			<textarea name="title"placeholder="제목"  rows="1" cols="150"  required></textarea><br>
			<textarea name="content" rows="15" cols="150" placeholder="내용" required></textarea><br>
			<div style ="margin-top:10px">
				<input type="file" name="img" value=img><br>
				<input type="hidden" name="user_id" value=user_id>
			</div>	
			<div style ="margin-top:15px;margin-left:900px;">
        		<input type="submit" value="등록">  
        		<button onclick="location.href='view/board/board.do'" type="button">돌아가기</button>    
        	</div>  	
    	</form>    	
	
</body>
</html>


요긴 입력화면 입니다.


at co.dev.web.FrontController.service(FrontController.java:119) 여기 코드는

controller.execute(request, response); 이거입니다 ㅜㅜ 미치겠네요

0
  • 답변 1

  • 자바마스터하고파
    43
    2022-05-21 15:12:45

    정부 프레임워크에는 게시판은 없는건가요??

  • 로그인을 하시면 답변을 등록할 수 있습니다.