• jsp关于include html、jsp等文件出现乱码问题的解决方案


    一般来说使用jsp标签<jsp:include>引入一个jsp文件:

    ①可以在被引入的jsp中加入:<%@ page contentType="text/html;charset=UTF-8" language="java" %>

    ②在当前项目的web.xml中加入:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
        http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    
    
        <jsp-config>
            <jsp-property-group>
                <description>jsp encoding example</description>
                <display-name>JSPConfiguration</display-name>
                <url-pattern>*.jsp</url-pattern>
                <el-ignored>false</el-ignored>
                <page-encoding>UTF-8</page-encoding>
                <scripting-invalid>false</scripting-invalid>
            </jsp-property-group>
    
            <jsp-property-group>
                <display-name>JSPConfiguration</display-name>
                <url-pattern>*.html</url-pattern>
                <el-ignored>false</el-ignored>
                <page-encoding>UTF-8</page-encoding>
                <scripting-invalid>false</scripting-invalid>
            </jsp-property-group>
    
            <jsp-property-group>
                <display-name>JSPConfiguration</display-name>
                <url-pattern>*.ftl</url-pattern>
                <el-ignored>false</el-ignored>
                <page-encoding>UTF-8</page-encoding>
                <scripting-invalid>false</scripting-invalid>
            </jsp-property-group>
        </jsp-config>
    
    </web-app>

    提示:在有些编译器中可能会提示错误,但是加入后仍可以运行,并且没有出现什么致命错误。

  • 相关阅读:
    Java 高级文件处理
    drf10
    drf9
    drf8
    drf7
    drf6
    drf5
    drf4
    drf3
    drf2
  • 原文地址:https://www.cnblogs.com/wuyou/p/3286346.html
Copyright © 2020-2023  润新知