nutz, Coming tonight (11): first in 2015, how to limit the entry method to POST

original
2015/01/04 12:52
Reading number 835

For example, how to limit the entry method of login to only POST requests and which request methods are allowed


 @At("/login") @Ok("json") public boolean login(@Param("name")String name, @Param("passwd")String passwd, HttpSession session) {    User user = dao.fetch(User.class, name);    if (user == null)        return false;    String tmp = Lang.sha1(user.getSalt()+passwd+user.getSalt());    if (user.getPasswd().equal(tmp)) {        session.setAttribute("uid", user.getId());        return true;    }    return false; }

-----------------------------The first dividing line in 2015-----------------------------

Answer of last issue:

UTF8JsonView supports four abbreviations: full, compact, nice, forLook. You should understand the name

 @Ok("json:full") @Ok("json:compact") @Ok("json:nice") @Ok("json:forLook")

If detailed settings are required, write a json according to the JsonFormat attribute, such as ignoring null values and skipping the passwd attribute

 @Ok("json:{ignoreNull:true, locked:'passwd'}")





Expand to read the full text
Loading
Click to join the discussion 🔥 (2) Post and join the discussion 🔥
Reward
two comment
zero Collection
zero fabulous
 Back to top
Top