如何在表单操作中使用相对路径
<form action="/myapp/alterPassword" id="changepassword" method="post"
autocomplete="off" onsubmit="return checkPassword();">
<div
style="display: block; position: absolute; top: 15%; left: 35%; width: 480px;">
在上面的代码中,有没有办法使用相对路径而不是 myapp/alterPassword ?
您可以动态打印上下文路径,如下所示:
<form action="${pageContext.request.contextPath}/alterPassword" ...>
或者使用 HTML<base>
标签,以便页面中的所有相对链接都与其相关。
也可以看看:
- 调用转发到 JSP 的 Servlet 时,浏览器无法访问/查找 CSS、图像和链接等相关资源 https://stackoverflow.com/questions/3655316/browser-cant-access-css-and-images-when-calling-a-servlet-which-forwards-to-a-j/3658735#3658735
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)