如何Cache-Control在Spring Boot中为静态资源添加HTTP头?
尝试在应用程序中使用过滤器组件,它正确地写入标头,但Cache-Control标头被覆盖.
@Component
public class CacheBustingFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
throws IOException, ServletException {
HttpServletResponse httpResp = (HttpServletResponse) resp;
httpResp.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
httpResp.setHeader("This-Header-Is-Set", "no-cache, no-store, must-revalidate");
httpResp.setHeader("Expires", "0");
chain.doFilter(req, resp);
}
Run Code Online (Sandbox Code Playgroud)
我在浏览器中得到的是:
Cache-Control:no-store
This-Header-Is-Set:no-cache, no-store, must-revalidate
Expires:0
Run Code Online (Sandbox Code Playgroud)
我想要的是:
Cache-Control:no-cache, no-store, must-revalidate
This-Header-Is-Set:no-cache, no-store, must-revalidate
Expires:0
Run Code Online (Sandbox Code Playgroud) 有谁知道为什么最后一个不起作用?
object nullObj = null;
short works1 = (short) (nullObj ?? (short) 0);
short works2 = (short) (nullObj ?? default(short));
short works3 = 0;
short wontWork = (short) (nullObj ?? 0); //Throws: Specified cast is not valid
Run Code Online (Sandbox Code Playgroud) 在VS2012中专门针对MVC的快捷方式存在问题.
组合键(CTRL + M,CTRL + G)绑定到当前不可用的命令(Go To View).
但是例如Refactor-> Rename work.
我看了相关的问题:快捷键不起作用(带有ASP.NET MVC 3 RC1的Visual Studio 2010)
以前在VS2010中遇到过这个问题,并且接受的答案解决了这个问题.