我正在使用带有 ExtJS 作为前端的 Spring security 3.1。这是我的 security-config.xml 文件。
<security:http auto-config="true" use-expressions="true">
<security:intercept-url pattern="/login.html" access="permitAll()" />
<security:intercept-url pattern="/**.html" access="isAuthenticated()" />
<security:form-login login-page="/login.html"
authentication-failure-url="/login.html"
default-target-url="/index.html" always-use-default-target="true"/>
<security:logout/>
</security:http>
我的 ExtJS 4.0 登录控制器。
doLogin: function(formItem) {
var loadingMask = new Ext.LoadMask(Ext.getBody(), {msg:"Logging in..."});
loadingMask.show();
var lp = formItem.up('loginpanel');
var form = lp.getForm();
console.log(form);
form.submit({
clientValidation: true,
method: 'POST',
url: "j_spring_security_check",
/*
params: {
newStatus: 'delivered'
},
*/
success: function() {
loadingMask.destroy();
window.location = '/index.html';
Ext.Msg.alert('Success', action.result.msg);
},
failure: function(form, action) {
form.reset();
loadingMask.destroy();
switch (action.failureType) {
case Ext.form.action.Action.CLIENT_INVALID:
Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values');
break;
case Ext.form.action.Action.CONNECT_FAILURE:
Ext.Msg.alert('Failure', 'Ajax communication failed');
break;
case Ext.form.action.Action.SERVER_INVALID:
Ext.Msg.alert('Failure', action.result.msg);
}
}
});
我的 Spring 登录控制器。
public class LoginController {
private static final Logger logger = LoggerFactory.getLogger(LoginController.class);
@RequestMapping(value = "/login.html", method = RequestMethod.GET)
public String login(Model model, @RequestParam(required=false) String message) {
model.addAttribute("message", message);
return "login";
}
现在,如果我单击登录按钮表单,它会重定向到 index.html,但 ExtJs 中的 index.html 需要 JSON 字符串 true 或 false,它会抛出 JSON 错误。
Uncaught You're trying to decode an invalid JSON String:
我知道 AuthenticationProcessingFilter 已被删除。现在我需要通过登录控制器返回成功的真字符串。任何帮助,将不胜感激 。