setcharacterencodingfilter.java
来自「基于Jabber协议的即时消息服务器」· Java 代码 · 共 43 行
JAVA
43 行
/** * $RCSfile$ * $Revision: 749 $ * $Date: 2004-12-26 18:53:31 -0800 (Sun, 26 Dec 2004) $ * * Copyright (C) 2004 Jive Software. All rights reserved. * * This software is published under the terms of the GNU Public License (GPL), * a copy of which is included in this distribution. */package org.jivesoftware.util;import javax.servlet.*;import java.io.IOException;/** * Sets the character encoding to UTF-8. * * @author Matt Tucker */public class SetCharacterEncodingFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException { } public void destroy() { } /** * Sets the character encoding to be used for any content passing out of this filter. */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { request.setCharacterEncoding("UTF-8"); response.setContentType("text/html; charset=" + "UTF-8"); chain.doFilter(request, response); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?