NutzCN Logo
问答 重定向视图总是不受控制
发布于 3016天前 作者 bigcatzeng 1895 次浏览 复制 上一个帖子 下一个帖子
标签:

为什么不管我返回什么串, 都跳转到@Fail("redirect:/user/login")


@At("/changePwd") @POST @Ok("redirect:/user/change_pwd?p=${parameters}") @Fail("redirect:/user/login") public String changePwd(@Param("p") String parameters, @Param("password") String password, @Param("password2") String password2, HttpServletRequest request, HttpServletResponse response) throws Exception { ,,, }
9 回复

抛异常才会走@Fail

不抛也走@Fail, :(

@At("/changePwd")
@GET
@Ok("beetl:user/change_pwd.html")
public Context changePwd(HttpSession session, @Param("p") String parameters) {
    log.debugf("changePwd ---> " + new Date());

.....}

@At("/changePwd")
@POST
@Ok("redirect:/user/change_pwd?p=${parameters}")
@Fail("redirect:/user/login")
public String changePwd(@Param("p") String parameters, @Param("password") String password,
@Param("password2") String password2, HttpServletRequest request, HttpServletResponse response)
throws Exception {

    ThreeDESUtil tools = new ThreeDESUtil();

    log.info("parameters:" + parameters);
    log.info("passwordA:" + password);
    log.info("passwordB:" + password2);

    Map<String, Object> map = tools.base64ToMap(parameters);

    String uid = (String) map.get("uid");
    String salt = (String) map.get("salt");
    String email = (String) map.get("email");
    String expire = (String) map.get("expire");

    String warning_message = (String) map.get("warning_message");

    log.info("uid:" + uid);
    log.info("salt" + salt);
    log.info("email" + email);
    log.info("expire:" + expire);
    log.info("warning_message:" + warning_message == null ? "null" : warning_message);

    if (!Toolkit.checkPwd(password)) {
       // 模板直接访问users
       map.put("warning_message", "the password must be 8+ characters with at least 1 number!");
       return tools.mapToBase64(map);
    }

    if (!password2.equals(password)) {
       map.put("warning_message", "The tow password not same!");
       return tools.mapToBase64(map);
    }

    int re = userService.updatePassword( map, Integer.valueOf(uid), salt, password);
    if (re < 1) {
       return tools.mapToBase64(map);
    }

    {
       Exception e = new Exception("the password reset success."); // 创建异常对象
       throw e; // 抛出异常
    }
}

找到问题了, 被拦截到登录窗口:)

不过返回的串没有填充到${parameters}, 咋整?

文档里说: 如果没有这个参数,入口函数返回什么,直接 toString() 以后填充, 我填${p.pp}没有把返回值贴过去啊

返回值是 ${obj}

我的问题解决了,不打扰你了,谢谢!

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