lishunli / nutz

Automatically exported from code.google.com/p/nutz

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MVC module 如何设置 no-cache 或 cache

GoogleCodeExporter opened this issue · comments

天行健(119588911) 14:50:23
Mvcs.java
...
public static void write(HttpServletResponse resp, Object obj, JsonFormat 
format)
throws IOException {
resp.setHeader("Cache-Control", "no-cache");
......
}
...... 
天行健(119588911) 14:50:23
如果业务逻辑里面需要cache 怎么办? 
天行健(119588911) 14:52:05
就是说每个module是否需要 
no-cache,应该由用户来决定。似乎不应该有Nutz框架来写死掉。 
天行健(119588911) 14:55:25
以 HelloWorld.say() 
为例,是否需要no-cache,有say()代码来决定比较好。如:
public String say(HttpServletResponse res) {
  res.setHeader("Cache-Control", "no-cache");
  return "Hello world " + System.currentTimeMillis();
}
但是如果是空参say(),如何拿到HttpServletResponse?

Original issue reported on code.google.com by jiongs...@gmail.com on 20 May 2010 at 6:58

这个可以由 ActionFilter 来设置,请参看 wiki:

http://code.google.com/p/nutz/wiki/mvc_action_filter

Original comment by zozoh...@gmail.com on 20 May 2010 at 9:18

  • Changed state: WontFix
  • Added labels: FAQ
  • Removed labels: ****
ActionFilter不可以设置这个Cache-Control,因为写死的这句res.setHea
der("Cache-Control", "no-cache");是在所有的ActionFilter之后执行的~

Original comment by blo...@gmail.com on 4 Sep 2013 at 2:26

  • Added labels: ****
  • Removed labels: ****
自定义一个View,简单方便

Original comment by wendal1985@gmail.com on 4 Sep 2013 at 2:51

  • Added labels: ****
  • Removed labels: ****