qq_32763435 2015-11-20 03:17 采纳率: 0%
浏览 10504
已采纳

新手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 onlyoffice编辑完后立即下载,下载的不是最新编辑的文档
  • ¥15 求caverdock使用教程
  • ¥15 Coze智能助手搭建过程中的问题请教
  • ¥15 12864只亮屏 不显示汉字
  • ¥20 三极管1000倍放大电路
  • ¥15 vscode报错如何解决
  • ¥15 前端vue CryptoJS Aes CBC加密后端java解密
  • ¥15 python随机森林对两个excel表格读取,shap报错
  • ¥15 基于STM32心率血氧监测(OLED显示)相关代码运行成功后烧录成功OLED显示屏不显示的原因是什么
  • ¥100 X轴为分离变量(因子变量),如何控制X轴每个分类变量的长度。