接口文档管理工具 RAP的2个常见问题及解决

一、取消登录验证码

    rap每隔一段时间会登录 session 失效,然后重新登录,半天左右时间可能要反复登录好几次。虽然登录时,chrome 是可以记住用户名密码的,但还要再输入验证码,并且验证码难以辨认经常输错。考虑到是本地部署 rap,对验证码的需求不大,因此修改三处代码关闭掉验证码验证。

    (1)修改com.taobao.rigel.rap.account.web.action.AccountAction的doLogin方法,注释掉如下代码即可:

        /* 去掉验证码限制
         * String kaptchaExpected = (String)session.get(com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY);
        if(getKaptcha() == null || !getKaptcha().equals(kaptchaExpected)) {
            setErrMsg("验证码错误");
            return ERROR;
        }
        */

    (2)修改\src\main\webapp\tcom\template.rap.vm,注释掉如下代码:

<--
<input name="kaptcha" class="form-control" type="text" value="" placeholder="请输入验证码" style="width:200px;margin-top:10px;">
<img src="/Kaptcha.jpg" onclick="this.src='/Kaptcha.jpg?' + Math.random()" style="margin-top: 5px;">
-->

    (3)修改\src\main\webapp\account\login.vm,注释掉如下代码:

<--
<div class="form-group">
            <label for="kaptcha">验证码</label>
            <input name="kaptcha" class="form-control" type="text" value="" placeholder="请输入验证码"/>
            <img src="/Kaptcha.jpg" onclick="this.src='/Kaptcha.jpg?' + Math.random()" style="margin-top: 5px;">
</div>
-->

    上述修改完成重新发布即可。

二、延长session过期时间

    rap的默认session过期时间过短,导致一天要登录多次rap,经常在保存接口数据的时候提示登录失效要重新登录,比较影响工作效率,因此修改几处配置延长session过期时间(我这里是设置为7天)。

    (1)修改com.taobao.rigel.rap.common.listener.SessionListener的sessionCreated方法:

    增加代码event.getSession().setMaxInactiveInterval(86400*7)

public void sessionCreated(HttpSessionEvent event) {
        ServletContext context = event.getSession().getServletContext();
        //设置session过期时间
        event.getSession().setMaxInactiveInterval(86400*7);//秒钟
        // online users count processing
        String key = ContextManager.KEY_COUNT_OF_ONLINE_USER_LIST;
        if (context.getAttribute(key) == null) {
            context.setAttribute(key, 0);
        }
        int curCountOfOnlineuserList = (Integer) context.getAttribute(key);
        context.setAttribute(key, curCountOfOnlineuserList + 1);
    }

    (2)修改src\main\webapp\WEB-INF\web.xml,把session-timeout时间修改为10080分钟。

 <session-config>
        <session-timeout>10080</session-timeout>
    </session-config>

    (3)修改Tomcat/conf/web.xml,把session-timeout时间修改为10080分钟。

<session-config>
        <session-timeout>10080</session-timeout>
    </session-config>

    上述修改完成重新发布即可。

转载于:https://my.oschina.net/dong706/blog/1786188

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值