關於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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM