【问题标题】:Getting 404error when trying to display a jsp尝试显示 jsp 时出现 404error
【发布时间】:2019-01-25 03:40:55
【问题描述】:

我正在尝试从 jsp 中获取表单的值以在控制器中的函数中使用并显示另一个 jsp

<form action="/uc">
   <input name="cnp" type="text">
      <br>
      <br>
   <input type="submit" value="Find">
</form>

这是我的Controller方法

 @RequestMapping(value = "/uc", method = RequestMethod.GET)
    public String userContracts(@RequestParam("cnp") String cnp, Model model)
    {
        List<Contract> ContractList = new ArrayList<Contract>();

        ContractList = cl.getContractsOfUser(cnp);

        model.addAttribute("ContractList", ContractList);
        System.out.println("In uc");
        return "UserContracts";
    }

【问题讨论】:

  • 您能否确认上下文已添加到正在运行的 uri 中

标签: java spring jsp controller


【解决方案1】:

感谢 pedram ezzati 的帮助!

问题是我不得不使用

<form action="http://localhost:8080/SpringWebTemplate/uc.html"> 

我之前的尝试要么没有 .html,要么只使用 /uc

【讨论】:

    【解决方案2】:

    确保您的包裹在春天来临时被扫描。

    在 app-config.xml 文件中检查下面的标签

    context:component-scan base-package="com.test.ashok"

    【讨论】:

    • 不,不是这样
    猜你喜欢
    • 2019-08-04
    • 1970-01-01
    • 2015-03-09
    • 2021-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多