Grails. Ways to set the timeout interval of a session. Which better?
I know two ways to set the timeout interval of a session:
way 1:
grails install-templates
Then edit src/templates/war/web.xml
way 2:
write this line of code in your contr开发者_StackOverflow社区oller:
session.setMaxInactiveInterval(sec);
Which of these ways do you think is better - and why?
Changing the value in web.xml is best if you want a constant value for all sessions.
setMaxInactiveInterval
is useful when you want to programmatically determine the current session's max length, but it's overkill to just set the value repeatedly to the same value.
精彩评论