java Springboot war文件contextpath不适用于tomcat
使用tomcat并将war文件部署到tomcat时,contextPath
不起作用。它在eclipse嵌入tomcat中运行良好。将war文件上传到tomcat时,它跳过了上下文路径
这是我在^{
<script>
function updateRow(index) {
const contextPath= "${pageContext.request.contextPath}";
storageTypeUrl= $('select[name=storageType]').val() == "session" ? "sessionOperations" : "operations";
$.ajax({
async: false,
type: "PUT",
url: contextPath+"/"+storageTypeUrl+"/?index="+index+"&iban="+document.getElementById(index+"iban").value
+"&businessIdentifierCode="+document.getElementById(index+"businessIdentifierCode").value,
success: function(data){
console.log("update Row successful");
},
error : function(request,error) {
alert(error);
}});
}
function createRow() {
const contextPath= "${pageContext.request.contextPath}";
storageTypeUrl= $('select[name=storageType]').val() == "session" ? "sessionOperations" : "operations";
$.ajax({
async: false,
type: "POST",
url: contextPath+"/"+storageTypeUrl+"/?iban="+document.getElementById("createIban").value
+"&businessIdentifierCode="+document.getElementById("createBusinessIdentifierCode").value,
success: function(data){
console.log("create Row successful");
},
error : function(request,error) {
alert(error);
}});
}
function deleteRow(index,id) {
const contextPath= "${pageContext.request.contextPath}";
storageTypeUrl= $('select[name=storageType]').val() == "session" ? "sessionOperations" : "operations";
$.ajax({
async: false,
type: "DELETE",
url: contextPath+"/"+storageTypeUrl+"/?index="+index,
success: function(data){
console.log("delete Row successful");
},
error : function(request,error) {
alert(error);
}});
}
</script>
如果单击“更新”、“创建”或“删除”,则得到404,URL将跳过contextPath并重定向到localhost:8080
,而不是localhost:8080/web-1.0-SNAPSHOT/
GET http://localhost:8080/?storageType=session&accountList%5B0%5D.iban=initIban&accountList%5B0%5D.businessIdentifierCode=initBusinessIdentifierCode&accountList%5B1%5D.iban=&accountList%5B1%5D.businessIdentifierCode= 404
但如果我刷新页面,就会创建新行
共 (0) 个答案