我是JSP的新手,我正处理一个令人困惑的问题.我有一个JSP表单,位于我的web-app中名为"admin"的子文件夹中(名为"CMS").
CMS/admin/display_content.jsp
Run Code Online (Sandbox Code Playgroud)
我的表单具有以下action和method属性值
<form action="/deleteContent" method="POST">
Run Code Online (Sandbox Code Playgroud)
/ deleteContent是名为DeleteContentServlet的servlet的URL模式.它只是从DB中删除用户选择.无论如何,我的问题是,一旦我点击提交,我注意到我的地址栏中输入的URL不正确.而不是得到
http://localhost:8080/CMS/deleteContent
Run Code Online (Sandbox Code Playgroud)
我明白了
http://localhost:8080/deleteContent
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题 ?当我有子文件夹时,是否只用于导入的文件?谢谢.
<c:url>对所有网址使用JSTL 标记:
如果浏览器不接受cookie,它会在URL中写入会话ID:
<form action="<c:url value='/deleteContent'/>" method="POST">
Run Code Online (Sandbox Code Playgroud)对于链接,它还允许将参数传递给URL,并对它们进行正确编码(通过<c:param>内部标记).