【发布时间】:2026-02-16 22:15:01
【问题描述】:
这是我的 ajax 帖子:
$("#defaultMigration").click(function(){
$.ajax({
type: "POST",
url: "/Svn2GitService/services/svn2git/defaultMigration",
contentType: 'application/json',
data: JSON.stringify({ svnUrl : $("#svnUrl").val(),
gitUrl : $("#gitUrl").val(),
username : $("#username").val(),
password : $("#password").val()
}),
dataType: 'text',
success: function(response){
alert("Success!" + response);
},
failure: function(response) {
alert("Error! " + response);
}
});
});
当我在我的服务中执行System.out.println 时,我看到svnUrl 参数是唯一接收任何东西的参数。事实上,它正在接收上述所有值。即 svn url、git url、用户名和密码。
为什么会这样?
【问题讨论】:
-
我认为你的问题是 URL 编码。如果
$("#svnUrl").val()或$("#gitUrl").val()在其值中包含&,则发送到服务器的源将在&符号处中断。