참고url
http://xens.tistory.com/237
http://georgovassilis.blogspot.kr/2012/03/spring-pathvariable-mapping-incomplete.html
web.xml
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<!-- <url-pattern>*.do</url-pattern> --> 수정전
<url-pattern>/</url-pattern> -->수정후 ( 여기때문에 되게 고생했다.. 설정안하면404 떨어진다.. )
</servlet-mapping>
servlet-context.xml
<!-- spring @pathVariable사용하려면 설정 -->
<beans:bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMet hodHandlerAdapter">
<beans:property name="alwaysUseFullPath" value="true" />
</beans:bean>
<beans:bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotati onHandlerMapping">
<beans:property name="alwaysUseFullPath" value="true" />
</beans:bean>
controller
@RequestMapping(value="/board/{seq}", method=RequestMethod.GET)
public ModelAndView boardSeq(@PathVariable("seq")String seq )throws Exception{
try{
logger.info("seq(get) :"+seq);
return new ModelAndView("/board/board.tiles");
}catch(Exception e){
logger.error(e.getMessage());
e.printStackTrace();
return new ModelAndView("/error.tiles");
}
}
@RequestMapping(value ="/board")
public ModelAndView board(BoardVO boardVO, HttpServletRequest request, HttpServletResponse response)throws Exception{
try{
List<BoardVO> list = boardDaoImpl.selectBbs();
return new ModelAndView("/board/board.tiles","list",list);
}catch(Exception e){
logger.error(e.getMessage());
e.printStackTrace();
return new ModelAndView("/error.tiles");
}
}
요청 url ==>
http://localhost:8080/board/seee -> 바로위 처음 controller
http://localhost:8080/board ->바로위두번째 controller
'Programming > Spring' 카테고리의 다른 글
Spring 태그 <form:form> <form:select> (0) | 2015.06.10 |
---|---|
전자정부프레임워크 JUNIT 을 이용한 테스트 (0) | 2015.06.10 |
[전자정부프레임워크] "알 수 없는 오류가 발생하였습니다." 라는 에러 메시지가 발생했을 때 대처법 (0) | 2015.06.04 |
[전자정부프레임워크] 공통서비스 - 게시판 익명처리 (0) | 2015.06.02 |
[전자정부프레임워크] CommandMap 으로 파라미터를 가져오지 못할떄 (0) | 2015.06.02 |