새바리
10
2019-08-06 10:39:34
3
212

jsp에러 모르겠어요


====================에러내용=========================


8월 06, 2019 10:30:12 오전 org.apache.catalina.core.StandardWrapperValve invoke

심각: Servlet.service() for servlet [board.BoardController] in context with path [] threw exception

java.lang.NumberFormatException: null

at java.lang.Integer.parseInt(Unknown Source)

at java.lang.Integer.valueOf(Unknown Source)

at board.BoardController.doGet(BoardController.java:191)

at board.BoardController.doPost(BoardController.java:230)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)

at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)

at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)

at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)

at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)

at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)

at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

at java.lang.Thread.run(Unknown Source)


=======================Controller=============================


else if(url.contains("update.do")) {

BoardDTO dto = new BoardDTO();

//request 객체에 없는 파일업로드 기능을 구현한 객체

MultipartRequest multi=new MultipartRequest(request,

Constants.UPLOAD_PATH, Constants.MAX_UPLOAD, "utf-8", //UPLOAD_PATH : 업로드 위치, MAX_UPLOAD: 업로드최대크기

new DefaultFileRenamePolicy()); //이름이 중복되면 *1, *2, *3, *4....

String filename=" ";

int filesize=0;

System.out.println(multi.getFileNames());

System.out.println(multi);

try {

Enumeration files=multi.getFileNames(); //첨부파일 집합

while(files.hasMoreElements()) { //다음 요소가 있으면

String file1=(String)files.nextElement(); //다음 요소를 읽음

filename=multi.getFilesystemName(file1); //파일이름

File f1=multi.getFile(file1);

if(f1!=null) {

filesize=(int)f1.length(); //파일의 크기

}

}

} catch (Exception e) {

e.printStackTrace();

}

//수정폼에 작성한 내용들

String writer=multi.getParameter("writer");

String subject=multi.getParameter("subject");

String content=multi.getParameter("content");

String passwd=multi.getParameter("passwd");

String ip=request.getRemoteAddr();

System.out.println(writer);

System.out.println(content);

System.out.println(passwd);

int num=Integer.valueOf(multi.getParameter("num"));

dto.setNum(num);

dto.setWriter(writer);

dto.setSubject(subject);

dto.setContent(content);

dto.setPasswd(passwd);

dto.setIp(ip);

System.out.println(writer);

System.out.println(writer);

//새로운 첨부파일을 올리지 않은 경우(기존 첨부파일 정보를 사용)

if(filename==null || filename.trim().equals("")) {

BoardDTO dto2=dao.view(num);

String fName=dto2.getFilename();

int fsize=dto2.getFilesize();

int fDown=dto2.getDown();

dto.setFilename(fName);

dto.setFilesize(fsize);

dto.setDown(fDown);

} else {//새로운 첨부파일을 올린 경우

dto.setFilename(filename);

dto.setFilesize(filesize);

}

String result=dao.passwdCheck(num, passwd); //비밀번호 체크

if(result != null) { //비번이 맞으면 게시물 내용이 수정된 후 목록으로 이동

dao.update(dto);

String page="/board_servlet/list.do";

response.sendRedirect(page);

}else { //비번이 틀리면 되돌아가서 에러메시지가 출력됨

request.setAttribute("dto", dto);

String page="/board/edit.jsp?pwd_error=y";

RequestDispatcher rd=request.getRequestDispatcher(page);

rd.forward(request, response);

}

} //if의 끝



============== DAO =============

public void update(BoardDTO dto) { //게시물 수정

SqlSession session=MybatisManager.getInstance().openSession();

session.update("board.update",dto);

session.commit();

session.close();

}


=============sql문=================

<update id="update">

update board

set writer=#{writer}, subject=#{subject},

content=#{content}, filename=#{filename},

filesize=#{filesize}, down=#{down}

where num=#{num}

</update>

1
0
  • 답변 3

  • GAN
    1k
    2019-08-06 10:51:11

    int num=Integer.valueOf(multi.getParameter("num"));

    multi.getParameter("num") <- 이거 정수형으로 변환 가능한 문자열인지 확인해보세요.

    0
  • h76
    287
    2019-08-06 10:54:53

    int num=Integer.valueOf(multi.getParameter("num"));


    여기에 값은 잘 들어오나요?

    0
  • 새바리
    10
    2019-08-06 13:41:33

    아 해결했어요 <form>태그 제대로 안닫아서 에러났었네요 감사합니당

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