Worklight アプリを使用して、非常に単純なフォーム ベースの認証を実装しようとしました。しかし、ログイン機能を有効にすると、/apps/services/j_security_check が見つからないという 404 エラーで停止します。奇妙なことに、IBM の developerWorks サイトからフォーム ベースの認証サンプルを実行すると、問題なく動作します。違いがわかりません。認証に関係するすべての機能はまったく同じですが、自分のアプリではこのエラー メッセージが表示されます。ソースからの関連部分は次のとおりです。
var sampleAppRealmChallengeHandler = WL.Client.createChallengeHandler("SampleAppRealm");
sampleAppRealmChallengeHandler.isCustomResponse = function(response) {
if (!response || response.responseText === null) {
return false;
}
var indicatorIdx = response.responseText.search('j_security_check');
if (indicatorIdx >= 0){
return true;
}
return false;
};
sampleAppRealmChallengeHandler.handleChallenge = function(response) {
$.mobile.changePage($('#Login'));
$('#passwordInputField').val('');
};
sampleAppRealmChallengeHandler.submitLoginFormCallback = function(response) {
var isLoginFormResponse = sampleAppRealmChallengeHandler.isCustomResponse(response);
if (isLoginFormResponse){
sampleAppRealmChallengeHandler.handleChallenge(response);
} else {
$.mobile.changePage($('#page0'));
sampleAppRealmChallengeHandler.submitSuccess();
}
};
function proceedWithLogin() {
console.log("proceedWithLogin");
var reqURL = '/j_security_check';
var options = {};
options.parameters = {
j_username : $('#loginEmail').val(),
j_password : $('#loginPassword').val()
};
options.headers = {};
sampleAppRealmChallengeHandler.submitLoginForm(reqURL, options, sampleAppRealmChallengeHandler.submitLoginFormCallback);
}
何がこれを引き起こしているのでしょうか?見落としていた隠れたプロジェクト設定はありますか? ありがとう!