java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -
this question has answer here:
i trying making simple bbs i'm encountering following error,
warn : org.springframework.web.servlet.pagenotfound - no mapping found http request uri [/board/] in dispatcherservlet name 'appservlet'
i have tried solve error many times, have failed. how can solve error?
here web.xml, controllerand , servlet-context.
my web.xml
<?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 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <filter> <filter-name>encodingfilter</filter-name> <filter-class>org.springframework.web.filter.characterencodingfilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>euc-kr</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingfilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- creates spring container shared servlets , filters --> <listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> <!-- definition of root spring container shared servlets and filters --> <context-param> <param-name>contextconfiglocation</param-name> <param-value> /web-inf/spring/root-context.xml /web-inf/spring/appservlet/servlet-context.xml </param-value> </context-param> <!-- processes application requests --> <servlet> <servlet-name>appservlet</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <init-param> <param-name>contextconfiglocation</param-name> <param-value> /web-inf/spring/appservlet/servlet-context.xml </param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>appservlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app>
my controller
package com.onj.board; import java.io.fileoutputstream; import java.io.ioexception; import java.util.arraylist; import java.util.hashmap; import java.util.list; import java.util.map; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import javax.servlet.http.httpsession; import org.springframework.web.multipart.multipartfile; import org.springframework.web.multipart.multiparthttpservletrequest; import org.springframework.web.servlet.modelandview; import org.springframework.web.servlet.mvc.multiaction.multiactioncontroller; import com.board.model.boarddto; import com.board.model.commentdto; import com.board.service.boardservice; import com.board.util.encodinghandler; import com.board.util.pagehandler; public class boardmulticontroller extends multiactioncontroller { private boardservice boardservice; private pagehandler pagehandler; public void setboardservice(boardservice boardservice) { this.boardservice = boardservice; } public void setpagehandler(pagehandler pagehandler) { this.pagehandler = pagehandler; } modelandview mav = null; public modelandview list(httpservletrequest request, httpservletresponse response) throws exception { mav = new modelandview(); httpsession session = request.getsession(); if (session.isnew() == false) { session.invalidate(); } list<boarddto> list = null; string boardlistselect = request.getparameter("boardlistselect"); string boardlistsearchtext = request .getparameter("boardlistsearchtext"); map<string, object> searchmap = new hashmap<string, object>(); if (boardlistsearchtext != null) { searchmap.put("boardlistsearchtext", encodinghandler.tokor(boardlistsearchtext)); searchmap.put("boardlistselect", boardlistselect); mav.addobject("boardlistsearchtext", encodinghandler.tokor(boardlistsearchtext)); mav.addobject("boardlistselect", boardlistselect); } string pagenumber = request.getparameter("pagenumber"); int pagenum = 1; if (pagenumber != null) { pagenum = integer.parseint(pagenumber); } int totalcount = pagehandler.boardallnumber(searchmap); int totalpagecount = pagehandler.boardpagecount(searchmap); int startpage = pagehandler.boardstartpage(pagenum); int endpage = pagehandler.boardendpage(pagenum, searchmap); list<object> rownumberlist = new arraylist<object>(); rownumberlist = pagehandler.boardsetpagenumber(pagenum); searchmap.put("startrow", rownumberlist.get(0)); searchmap.put("endrow", rownumberlist.get(1)); list = boardservice.boardlist(searchmap); mav.addobject("pagenumber", pagenum); mav.addobject("boardcount", totalcount); mav.addobject("totalpagecount", totalpagecount); mav.addobject("startpage", startpage); mav.addobject("endpage", endpage); mav.addobject("list", list); mav.setviewname("list"); return mav; } public modelandview read(httpservletrequest request, httpservletresponse response) throws exception { string seq = request.getparameter("seq"); boarddto boarddto = boardservice.readcontent(seq); httpsession session = request.getsession(); session.setattribute("boarddto", boarddto); mav.addobject("boarddto", boarddto); mav.addobject("comment", boardservice.listcomment(seq)); mav.setviewname("read"); return mav; } public modelandview comment(httpservletrequest request, httpservletresponse response) throws exception { httpsession session = request.getsession(); boarddto boarddto = (boarddto) session.getattribute("boarddto"); mav = new modelandview("redirect:/read.html?seq=" + boarddto.getseq()); commentdto commentdto = new commentdto(); commentdto.setcomment_name(request.getparameter("comment_name")); commentdto.setcomment_comm(request.getparameter("comment_comm")); commentdto.setseq(boarddto.getseq()); boardservice.insertcomment(commentdto); return mav; } public modelandview write(httpservletrequest request, httpservletresponse response) throws exception { mav = new modelandview("write"); return mav; } public modelandview writeok(httpservletrequest request, httpservletresponse response) throws exception { mav = new modelandview("redirect:/list.html"); multiparthttpservletrequest mprequest = (multiparthttpservletrequest) request; string name = request.getparameter("name"); string passwd = request.getparameter("passwd"); string title = request.getparameter("title"); string content = request.getparameter("content"); multipartfile file = mprequest.getfile("file"); string filename = file.getoriginalfilename(); boarddto boarddto = new boarddto(); string filedir = "d:/upload/"; byte[] filedata; fileoutputstream output = null; if (!filename.equals("")) { // 파일 저장 try { filedata = file.getbytes(); output = new fileoutputstream(filedir + filename); output.write(filedata); } catch (ioexception e) { e.printstacktrace(); } { output.close(); } } else { filename = " "; } boarddto.setname(name); boarddto.setpasswd(passwd); boarddto.settitle(title); boarddto.setcontent(content); boarddto.setfilename(filename); boardservice.insertboard(boarddto); return mav; } public modelandview updatepagego(httpservletrequest request, httpservletresponse response) throws exception { httpsession session = request.getsession(); boarddto boarddto = (boarddto) session.getattribute("boarddto"); mav = new modelandview("update", "boarddto", boarddto); return mav; } public modelandview update(httpservletrequest request, httpservletresponse response) throws exception { httpsession session = request.getsession(); boarddto boarddto = (boarddto) session.getattribute("boarddto"); string name = request.getparameter("name"); string title = request.getparameter("title"); string content = request.getparameter("content"); string seq = boarddto.getseq(); boarddto.setname(name); boarddto.settitle(title); boarddto.setcontent(content); boarddto.setseq(seq); boardservice.updateboard(boarddto); mav = new modelandview("redirect:/read.html?seq=" + seq); return mav; } public modelandview delete(httpservletrequest request, httpservletresponse response) throws exception { mav = new modelandview(); httpsession session = request.getsession(); boarddto boarddto = (boarddto) session.getattribute("boarddto"); string boardpassword = boarddto.getpasswd(); string passwd = request.getparameter("passwd"); string mas = ""; if (boardpassword.equals(passwd)) { boardservice.deleteboard(boarddto.getseq()); mav.setviewname("redirect:/list.html"); } else { mas = "비밀번호가 일치하지 않습니다."; mav.addobject("mas", mas); mav.setviewname("redirect:/read.html?seq=" + boarddto.getseq()); } return mav; } }
my servlet-context.xml
<?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" xsi:schemalocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.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.xsd "> <!-- dispatcherservlet context: defines servlet's request-processing infrastructure --> <!-- <context:component-scan base-package="com.onj.board" /> --> <!-- enables spring mvc @controller programming model --> <annotation-driven /> <!-- handles http requests /resources/** efficiently serving up static resources in ${webapproot}/resources directory --> <resources mapping="/resources/**" location="/resources/" /> <beans:bean id="datasource" class="org.apache.commons.dbcp.basicdatasource" destroy-method="close"> <beans:property name="driverclassname" value="oracle.jdbc.driver.oracledriver" /> <beans:property name="url" value="jdbc:oracle:thin:@localhost:1521:ex" /> <beans:property name="username" value="study" /> <beans:property name="password" value="study" /> </beans:bean> <!-- resolves views selected rendering @controllers .jsp resources in /web-inf/views directory --> <beans:bean class="org.springframework.web.servlet.view.internalresourceviewresolver"> <beans:property name="prefix" value="/web-inf/jsp/" /> <beans:property name="suffix" value=".jsp" /> </beans:bean> <!-- 넘어오는 url에 따라 컨트롤러에서 실행될 메소드 매핑 --> <!-- propertiesmethodnameresolver는 prop key로 넘어오는 url에 대해 실행할 컨트롤러의 메소드 정의 --> <beans:bean id="usercontrollermethodnameresolver" class="org.springframework.web.servlet.mvc.multiaction.propertiesmethodnameresolver"> <beans:property name="mappings"> <beans:props> <beans:prop key="/list.html">list</beans:prop> <beans:prop key="/read.html">read</beans:prop> <beans:prop key="/comment.html">comment</beans:prop> <beans:prop key="/write.html">write</beans:prop> <beans:prop key="/writeok.html">writeok</beans:prop> <beans:prop key="/updatepage.html">updatepagego</beans:prop> <beans:prop key="/update.html">update</beans:prop> <beans:prop key="/delete.html">delete</beans:prop> </beans:props> </beans:property> </beans:bean> <!-- controller mapping --> <beans:bean name="/list.html /read.html /comment.html /write.html /writeok.html /updatepage.html /update.html /delete.html" class="com.onj.board.boardmulticontroller"> <beans:property name="methodnameresolver" ref="usercontrollermethodnameresolver" /> <beans:property name="boardservice" ref="boardservice" /> <beans:property name="pagehandler" ref="pagehandler" /> </beans:bean> </beans:beans>
i need advice.
thanks
try changing <url-pattern>
in web.xml file to:
<url-pattern>/*</url-pattern>
how deploying application? board.war
?
also, let know, ancient way of configuring spring mvc application. spring has guides available demonstrating modern approach.
Comments
Post a Comment