1. 程式人生 > >關於controller中地址找不到的情況

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