在index.jsp上登錄——>login.jsp頁面。
login.jsp上有兩個靜態的連接add.jsp和sel.jsp
然後點add.jsp 是一個添加用戶的表單 輸入數據提交後
沒有任何顯示 debug報:
2015-11-20 11:06:56,613 [http-bio-9090-exec-10] DEBUG [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] - Looking up handler method for path /view/adduser
2015-11-20 11:06:56,616 [http-bio-9090-exec-10] DEBUG [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] - Did not find handler method for [/view/adduser]
2015-11-20 11:06:56,617 [http-bio-9090-exec-10] DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - Matching patterns for request [/view/adduser] are [/**]
2015-11-20 11:06:56,617 [http-bio-9090-exec-10] DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - URI Template variables for request [/view/adduser] are {}
2015-11-20 11:06:56,617 [http-bio-9090-exec-10] DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - Mapping [/view/adduser] to HandlerExecutionChain with handler [org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler@6aa25d] and 1 interceptor
2015-11-20 11:06:56,618 [http-bio-9090-exec-10] DEBUG [org.springframework.web.servlet.DispatcherServlet] - Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2015-11-20 11:06:56,618 [http-bio-9090-exec-10] DEBUG [org.springframework.web.servlet.DispatcherServlet] - Successfully completed request
我的controller :
@RequestMapping("/adduser")
public ModelAndView addUser(ModelMap model, HttpServletRequest request, HttpServletResponse response) {
ModelAndView mav = new ModelAndView("adduser");
System.out.println("添加controller被調用");
Integer userId = Integer.parseInt(request.getParameter("id").trim());
String userName = request.getParameter("uname").trim();
String userPassword = request.getParameter("upass").trim();
String userEmail = request.getParameter("email");
User user =userService.addUser(userId, userName, userPassword, userEmail);
System.out.println(user);
return mav;
}
<mvc:annotation-driven />
<mvc:default-servlet-handler /> 的配置和
<!-- 攔截設置 -->
<servlet-mapping>
<servlet-name>dispatcherServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>都有配置。
控制台上並沒有被調用的信息。請問為什麼?
Did not find handler method for [/view/adduser]沒有這路徑,不是/adduser它,可以在你controller類上面加上@RequestMapping(“/view”)