程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> 表單-新手spring,controller沒有被調用問題

表單-新手spring,controller沒有被調用問題

編輯:編程綜合問答
新手spring,controller沒有被調用問題

在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”)

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved