JFinal 如何整合shiro

依据http://www.jfinal.com/project/22

写了一个logincontroller

com.cn.kcgl.entity.Menu;
com.cn.kcgl.jeeweb.shiro.UserRealm;
com.cn.kcgl.jeeweb.utils.UserUtils;
com.jfinal.core.;
com.jfinal.core.Controller;
org.apache.shiro.SecurityUtils;
org.apache.shiro.authz.annotation.;
org.apache.shiro.authz.annotation.;
org.apache.shiro.subject.Subject;
org.springframework.ui.Model;
org.springframework.web.bind.annotation.;
org.springframework.web.bind.annotation.;
org.springframework.web.servlet.ModelAndView;

javax.servlet.http.HttpServletRequest;


LoginController Controller {

    index(){
       System..println();
      render();
    }

(value = )
login() {
      String username = getPara();
      String password = getPara();
      render();
   }

}

前台 login.html

<form id="loginform"  action="${ctxPath}/login" method="post">
<div class="form-group has-feedback">
<input type="text" class="form-control" placeholder="username"/>
<span class="glyphicon glyphicon-user form-control-feedback"/>
</div>
<div class="form-group has-feedback">
<input type="password" class="form-control" placeholder="Password">
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
</form>
点击登录http://localhost:8093/login 后台为什么调用index()方法 在哪里可以设置下呢!


评论区

lwcompany

2018-07-19 14:51

调用index

JFinal-3.4 action report -------- 2018-07-19 14:44:15 --------------------------
Url : POST /login
Controller : com.cn.kcgl.controller.LoginController.(LoginController.java:1)
Method : index
--------------------------------------------------------------------------------
我想调用login方法

JFinal

2018-07-19 17:54

看一下 jfinal 的路由规则,只有四个规则,3 分钟内学会:
http://www.jfinal.com/doc/2-3

lwcompany

2018-07-21 10:55

@JFinal 点击登录按钮,想调用login方法,为什么总是调用index方法
shiro.ini文件
[main]
#realm
userRealm=com.cn.kcgl.jeeweb.shiro.UserRealm
securityManager.realm=$userRealm
authc.loginUrl = /a/login
authc.successUrl = /a/index
logout.redirectUrl = /a/login
[urls]
/index = authc
/a/logout = logout--------------在哪里修改呢?

lwcompany

2018-07-21 10:56

public void configRoute(Routes me) {
me.add("/login", LoginController.class, "/views"); // 第三个参数为该Controller的视图存放路径

热门反馈

扫码入社