0

我正在尝试做 RESTful URL 映射

这就像当我输入 url 标签课程/板的值时,它进入 /curriculum1.4/controller.jspx 的路径

<url method="GET" value="curriculum/board">/curriculum1.4/controller.jspx</url>
<url method="GET" value="curriculum/board/write">/curriculum1.4/write_view.jsp</url>

现在我想更改 myscript.js 上的路径。jquery 在此路径课程/板上也不起作用我不知道为什么.. 它仍然是相同的 jsp 文件但为什么它不起作用?

myscript.js

function writeClick() {
    window.location.href = "write_view.jsp";
}
function listClick() {
    window.location.href = "controller.jspx";
}

我试过这样,但没有奏效。我应该如何改变路径?

function writeClick() {
        window.location.href = "curriculum/board/write";
    }
    function listClick() {
        window.location.href = "/curriculum/board";
    }

列表.jsp

<td colspan="5"><button onclick="writeClick();">write</button>

<input  type="button" value="list" onclick="listClick()" />&nbsp;&nbsp;</td>
4

1 回答 1

0

我希望两个网址都使用 GET 映射。尝试在浏览器中点击jsp

http://localhost:8080/curriculum1.4/controller.jspx
http://localhost:8080/curriculum1.4/write_view.jsp

注意:更改端口号(8080)。

如果找到完整链接,则替换 window.location.href 中的值。

尝试链接:

http://localhost:{your_port_number}/{project_name}/curriculum1.4/controller.jspx
http://localhost:{your_port_number}/{project_name}/{package_name}/curriculum1.4/controller.jspx
http://localhost:{your_port_number}/{project_name}/{resource_folder_name}/curriculum1.4/controller.jspx

还是找不到网址?检查以下链接。

Web 项目文件位置

jsp的链接

尝试使用 servlet。我想这是好的编程。

于 2018-11-12T10:36:41.677 回答