关于controller中地址找不到的情况

@RequestMapping(value = "anemd/{id}" , method = RequestMethod.GET)
    public String anemd(@PathVariable("id")Integer id ,Map<String, Object> map){ 
        List<String> sexlist = Arrays.asList("男","女");
        List<Integer> agelist = Arrays.asList(12,13,14,15,16,17,18,19,20);
        map.put("sexlist", sexlist);
        map.put("agelist", agelist);
     //用id获取数据 map.put(
"user", userService.selectUserId(id)); return "anemd"; } @RequestMapping(value = "../anemd" , method = RequestMethod.POST) public String anemd(User user){
    //查看修改后的值 System.out.println(user);
return "redirect:hello"; }

这是修改实例的controller中的修改

下方是HTML中的代码

<h1>修改用户信息</h1>
        <form:form action="anemd" commandName="user" method="post">
                <form:hidden path="id"/>
            名字:<form:input path="name"/><br/>
            性别:<form:radiobuttons path="sex" items="${sexlist }"/><br/>
            年龄:<form:radiobuttons path="age" items="${agelist }"/><br/>
            邮箱:<form:input path="email"/><br/>
            <input  type="submit" value="修改" />
        </form:form>

就算加上../也没什么作用??

经过修改后:

<h1>修改用户信息</h1>
        <form:form action="${pageContext.request.contextPath }/anemd" commandName="user" method="post">
                <form:hidden path="id"/>
            名字:<form:input path="name"/><br/>
            性别:<form:radiobuttons path="sex" items="${sexlist }"/><br/>
            年龄:<form:radiobuttons path="age" items="${agelist }"/><br/>
            邮箱:<form:input path="email"/><br/>
            <input  type="submit" value="修改" />
        </form:form>

猜你喜欢

转载自www.cnblogs.com/DENGJ/p/9790262.html