2012-10-10 3 views
1

나는 필터에 게시물 요청을 보내는 form.jsp.from을 가지고 있습니다.
spring.Here에서 컨트롤러에 요청을 보내고 있습니다. 사용자 정의 annotations.Here을 사용하고 있습니다. 여기에 ModelAndView.Whats가 아닌 String 유형의 응답을 반환해야합니다. 요청이 필터링되지만 컨트롤러가 아닙니다.
요청 : /sendRequest.htm
필터 코드 : RequestDispatcher rd = request.getRequestDispatcher ("/ sendRequest.htm"); rd.forward (request, response); 컨트롤러는 다음과 같습니다
http : // localhost : 8080/sendRequest.htm 404 (찾을 수 없음)

@Controller 
public class ResponseController{ 
    @RequestMapping(value="/sendRequest.htm",method = RequestMethod.POST) 
    public @ResponseBody String sendResponse(HttpServletRequest request,HttpServletResponse response){ 

    return "msg"; 
} 

그리고 내 스프링 ser.xml은 다음과 같습니다

<context:component-scan base-package="myPackage" /> <mvc:annotation-driven /> 

답변

1

나는 당신을 "/sendRequest.htm/sendRequest.htm"요청을 매핑하는 가정,하지에 "/sendRequest.htm"
클래스 선언에서 @RequestMapping ("/ sendRequest.htm")을 제거하고 메소드에 그대로 두십시오.

+1

정확히. 각 메소드에 대한 요청 매핑은 클래스에 대한 요청 매핑에 추가되므로이 경우에는 하나 또는 둘 다를 필요로하지만 가장 좋은 방법은 흰색을 제안하는 것입니다. – DavidA

+0

Sir 방금 클래스 수준 @ RequestMapping을 제거했지만 컨트롤러에 요청하지 않습니다. form.jsp에서 내 요청은 (/project/sendRequest.htm?action=enquiryform&fromReq=client)
요청을 전달하는 방법을 모릅니다. filter.plz의 컨트롤러가 내게 도움이됩니다 –

+1

web.xml에 DispatcherServlet의 서블릿 매핑은 무엇입니까? – white

관련 문제