NutzCN Logo
问答 今天不知怎么了shiro怎么都登陆不了, 总是跳到404错误
发布于 2809天前 作者 bigcatzeng 4762 次浏览 复制 上一个帖子 下一个帖子
标签:

authc = org.nutz.integration.shiro.CaptchaFormAuthenticationFilter
authc.loginUrl = /user/login
logout.redirectUrl= /user/login
提交登陆后, 总是返回404, 地址栏回到 http://localhost/3dazer/user/login
如果在地址栏回车就是进入正常登陆页面
控制台信息:

[ActionInvoker.http-nio-80-exec-11] Path=[/user/login] available methods[GET] but request [POST], using the wrong http method?
08-20 11:31:36.043  DEBUG - [UrlMappingImpl.http-nio-80-exec-11] Search mapping for path=/user/login : NOT Action match
8 回复

完整shiro.ini

来自炫酷的 NutzCN

[main]
sha256Matcher = org.apache.shiro.authc.credential.Sha256CredentialsMatcher
nutzdao_realm = com.laurelatsunset.designer.shiro.realm.NutDaoRealm
nutzdao_realm.credentialsMatcher = $sha256Matcher

authc = org.nutz.integration.shiro.CaptchaFormAuthenticationFilter
authc.loginUrl = /user/login
logout.redirectUrl= /user/login

[urls]
/rs/** = anon
/captcha/next= anon
/page/** = anon
/user/logout = logout
/user/error = anon
/user/profile/active/mail = anon
/user/** = authc
/** = authc

登陆成功也跳转到404, 地址栏回到 http://localhost/3dazer/user/login
在地址栏输入其它url可以确认登陆成功

@bigcatzeng 最后面的/**=authc是什么鬼

来自炫酷的 NutzCN

@bigcatzeng 建议改成新版的filter,在入口方法内做登录和状态判断,可以查看本站源码中的shiro.ini和UserModule

来自炫酷的 NutzCN

debug两天, 终于从坑里爬出来了!

因为换登陆UI, 发现的name属性被改成id了!如下:

加上name一切平息!

出错信息不精确啊, 控制台也没有消息, 反编译CaptchaFormAuthenticationFilter, 单步调试才找到原因.

谢谢wendal支持:)

UI 摘要:
入坑
....input type="text" class="form-control input-lg" id="captcha" placeholder="Text" required....
出坑
....input type="text" class="form-control input-lg" name="captcha" id="captcha" placeholder="Text" required....

填坑!
login页面用的是POST方法提交,不是ajax, 因此验证失败时还会返回404错误, shiro授权失败时跳转会 /user/login (POST)方法, 这个POST方法已经被删除, 所以抱错, 重新增加login的POST方法:
@At
@POST
@Ok("redirect:/user/login")
public void login(HttpSession session) {
return;
}
这样授权失败就会返回正常登陆页面.

添加回复
请先登陆
回到顶部