Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring JSP页面未使用正确的参数调用函数_Spring_Jsp - Fatal编程技术网

Spring JSP页面未使用正确的参数调用函数

Spring JSP页面未使用正确的参数调用函数,spring,jsp,Spring,Jsp,我正在开发一个具有JSP页面的Spring应用程序。在一个JSP页面中,我有3个操作。其中两个动作不需要任何参数,第三个动作有一个静态参数(/note/list/1234),1234是静态参数 如果我调用这两个函数中的任何一个,第三个函数应该使用静态参数并执行。而不是调用/note/list/0。我不知道为什么。我在下面发布JSP文件。请看一看 Note.JSP <h1> Add notes </h1> <c:url var="addAction" val

我正在开发一个具有JSP页面的Spring应用程序。在一个JSP页面中,我有3个操作。其中两个动作不需要任何参数,第三个动作有一个静态参数(/note/list/1234),1234是静态参数

如果我调用这两个函数中的任何一个,第三个函数应该使用静态参数并执行。而不是调用/note/list/0。我不知道为什么。我在下面发布JSP文件。请看一看

Note.JSP

<h1>
    Add notes
</h1>

<c:url var="addAction" value="/note/add" ></c:url>
<form:form action="${addAction}" commandName="notices">
    <table>
        <c:if test="${!empty notices.notetext}">
            <tr>
                <td>
                    <form:label path="noticesid">
                        <spring:message text="noticesid"/>
                    </form:label>
                </td>
                <td>
                    <form:input path="noticesid" readonly="true" size="8"  disabled="true" />
                    <form:hidden path="noticesid" />
                </td>
            </tr>
        </c:if>
        <tr>
            <td>
                <form:label path="notetext">
                    <spring:message text="notetext"/>
                </form:label>
            </td>
            <td>
                <form:input path="notetext"  />
            </td>
        </tr>
        <tr>
            <td>
                <form:label path="notetag" >
                    <spring:message text="notetag"/>
                </form:label>
            </td>
            <td>
                <form:input path="notetag"/>
            </td>
        </tr>
        <tr>
            <td>
                <form:label path="notecolor">
                    <spring:message text="notecolor"/>
                </form:label>
            </td>
            <td>
                <form:input path="notecolor" />
            </td>
        </tr>

        <tr>
            <td>
                <form:label path="canvasid">
                    <spring:message text="canvasid"/>
                </form:label>
            </td>
            <td>
                <form:input path="canvasid" />
            </td>
        </tr>

        <tr>
            <td>
                <form:label path="sectionid">
                    <spring:message text="sectionid"/>
                </form:label>
            </td>
            <td>
                <form:input path="sectionid"  />
            </td>
        </tr>

        <tr>
            <td>
                <form:label path="canvasnName">
                    <spring:message text="canvasnName"/>
                </form:label>
            </td>
            <td>
                <form:input path="canvasnName"  />
            </td>
        </tr>


        <tr>
            <td colspan="2">
                <c:if test="${!empty notices.noticesid}">
                    <input type="submit"
                           value="<spring:message text="Edit note"/>" />
                </c:if>
                <c:if test="${empty notices.notetext}">
                    <input type="submit"
                           value="<spring:message text="Add note"/>" />
                </c:if>
            </td>
        </tr>
    </table>
</form:form>
<br>

<h3>Notes List</h3>
<c:url var="listAction" value="/note/listing" ></c:url>
 <form:form action="${listNotes}" commandName="notices" method="post">
<c:if test="${!empty notices.noticesid}">
    <table class="tg">
        <tr>
            <th width="80">Notes ID</th>
            <th width="120">Notes text</th>
            <th width="120">Note Tag</th>
            <th width="120">Note color</th>
            <th width="120">Note section</th>
            <th width="120">Canvas id</th>
            <th width="120">Canvas name</th>
            <th width="120">Other id</th>
            <th width="60">Edit</th>
            <th width="60">Delete</th>
        </tr>
        <c:forEach items="${listNotes}" var="notices">
            <tr>
                <td>${notices.noticesid}</td>
                <td>${notices.notetext}</td>
                <td>${notices.notetag}</td>
                <td>${notices.notecolor}</td>
                <td>${notices.sectionid}</td>
                <td>${notices.canvasid}</td>
                <td>${notices.canvasnName}</td>
                <td>${notices.personid}</td>
                <td><a href="<c:url value='/editnote/${notices.noticesid}' />" >Edit</a></td>
                <td><a href="<c:url value='/removenote/${notices.noticesid}' />" >Delete</a></td>
            </tr>
        </c:forEach>
    </table>
</c:if>
</form:form>

<c:url var="listAction" value="/note/list/2323" ></c:url>  // This method here calls /note/list/0
<form:form action="${listNotes}" commandName="notices" method="post">
    <c:if test="${!empty notices.noticesid}">
        <table class="tg">
            <tr>
                <th width="80">Notes ID</th>
                <th width="120">Notes text</th>
                <th width="120">Note Tag</th>
                <th width="120">Note color</th>
                <th width="120">Note section</th>
                <th width="120">Canvas id</th>
                <th width="120">Canvas name</th>
                <th width="120">Other id</th>
                <th width="60">Edit</th>
                <th width="60">Delete</th>
            </tr>
            <c:forEach items="${listNotes}" var="notices">
                <tr>
                    <td>${notices.noticesid}</td>
                    <td>${notices.notetext}</td>
                    <td>${notices.notetag}</td>
                    <td>${notices.notecolor}</td>
                    <td>${notices.sectionid}</td>
                    <td>${notices.canvasid}</td>
                    <td>${notices.canvasnName}</td>
                    <td>${notices.personid}</td>
                    <td><a href="<c:url value='/editnote/${notices.noticesid}' />" >Edit</a></td>
                    <td><a href="<c:url value='/removenote/${notices.noticesid}' />" >Delete</a></td>
                </tr>
            </c:forEach>
        </table>
    </c:if>
</form:form>
</body>
</html>

我该怎么做才能让它被正确的URL调用,即/note/list/1234,即使我调用/note/add。任何帮助都很好。谢谢。

可能重复的@RomanC问题现在有点不同了。
@RequestMapping(value = "/note/list/{id}", method=RequestMethod.GET)
public String listNotes(@PathVariable int id,Model model) {
    System.out.println("Did we reach in noteslist");
    System.out.println("Section id is"+id);  // returns zero on first execution unless called manually with /note/list/{number}
    Person person = personService.getCurrentlyAuthenticatedUser();
      model.addAttribute("person", new Person());
    model.addAttribute("listPersons", this.personService.listPersons());
    model.addAttribute("listNotes",this.notesService.listNotesBySectionId(id,person));
    return "note";
}