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

新手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条)

报告相同问题?

悬赏问题

  • ¥15 (标签-python|关键词-char)
  • ¥15 python+selenium,在新增时弹出了一个输入框
  • ¥15 苹果验机结果的api接口哪里有??单次调用1毛钱及以下。
  • ¥20 学生成绩管理系统设计
  • ¥15 来一个cc穿盾脚本开发者
  • ¥15 CST2023安装报错
  • ¥15 使用diffusionbert生成文字 结果是PAD和UNK怎么办
  • ¥15 有人懂怎么做大模型的客服系统吗?卡住了卡住了
  • ¥20 firefly-rk3399上启动卡住了
  • ¥15 如何删除这个虚拟音频