qq_32763435
2015-11-20 03:17
采纳率: 91.7%
浏览 10.4k
已采纳

新手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>都有配置。


控制台上并没有被调用的信息。请问为什么?
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

7条回答 默认 最新

  • sinat_31535993 2015-11-20 07:19
    最佳回答

    Did not find handler method for [/view/adduser]没有这路径,不是/adduser它,可以在你controller类上面加上@RequestMapping(“/view”)

    评论
    解决 无用
    打赏 举报
查看更多回答(6条)

相关推荐 更多相似问题