公文收发系统开发随笔

1、中文文件下载:
public InputStream getInputStream() throws Exception {
        String file = Constants.DOCUMENT_PATH + getAttach().getFullFile();
        return ServletActionContext.getServletContext().getResourceAsStream(
                file);
    }
/**
     * 下载的时候,对文件名进行编码,解决了中文问题
     */
    protected String encoding(String str) throws Exception {
        String agent = getRequest().getHeader("USER-AGENT");
        if (null != agent && -1 != agent.indexOf("MSIE")) {
            return java.net.URLEncoder.encode(str, "UTF-8");
        } else if (null != agent && -1 != agent.indexOf("Mozilla")) {
            return new String(str.getBytes("UTF-8"), "ISO-8859-1");
        } else {
            return str;
        }
    }
<action name="DocumentDown" class="haotian.hsoa.action.admin.DocumentDownAction">
            <result name="success" type="stream">
                <param name="contentType">${document.docContentType}</param>
                <param name="inputName">inputStream</param>
                <param name="contentDisposition">attachment;filename="${downFileName}"</param>
                <param name="bufferSize">4096</param>
            </result>
        </action>
2、<pre>的问题:
pre {
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
}
* html pre {
word-wrap: break-word; /* Internet Explorer 5.5+ */
white-space : normal ; /* Internet Explorer 5.5+ */
}
文本中把"\r\n"替换成"<br/>"

你可能感兴趣的:(html,.net,css,Opera)