⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 httpcontenttype.java

📁 OS(OpenSymphony)的SiteMesh是一个用来在JSP中实现页面布局和装饰(layout and decoration)的框架组件
💻 JAVA
字号:
package com.opensymphony.module.sitemesh.filter;/** * Extracts the type and encoding from an HTTP Content-Type header. * * @author Scott Farquhar */public class HttpContentType {    private final String type;    private final String encoding;    public HttpContentType(String fullValue) {        // this is the content type + charset. eg: text/html;charset=UTF-8        int offset = fullValue.lastIndexOf("charset=");        encoding = offset != -1 ? extractContentTypeValue(fullValue, offset + 8) : null;        type = extractContentTypeValue(fullValue, 0);    }    private String extractContentTypeValue(String type, int startIndex) {        if (startIndex < 0)            return null;        // Skip over any leading spaces        while (startIndex < type.length() && type.charAt(startIndex) == ' ') startIndex++;        if (startIndex >= type.length()) {            return null;        }        int endIndex = startIndex;        if (type.charAt(startIndex) == '"') {            startIndex++;            endIndex = type.indexOf('"', startIndex);            if (endIndex == -1)                endIndex = type.length();        } else {            // Scan through until we hit either  the end of the string or a            // special character (as defined in RFC-2045). Note that we ignore '/'            // since we want to capture it as part of the value.            char ch;            while (endIndex < type.length() && (ch = type.charAt(endIndex)) != ' ' && ch != ';'                    && ch != '(' && ch != ')' && ch != '[' && ch != ']' && ch != '<' && ch != '>'                    && ch != ':' && ch != ',' && ch != '=' && ch != '?' && ch != '@' && ch != '"'                    && ch != '\\') endIndex++;        }        return type.substring(startIndex, endIndex);    }    public String getType() {        return type;    }    public String getEncoding() {        return encoding;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -