<%@ include>引生的编码问题

本文介绍了一种在web.xml中配置特定URL模式的编码方式,以解决包含HTML文件时出现中文乱码的问题。通过指定page-encoding为UTF-8,确保以html结尾的文件以UTF-8编码读取。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

大家知道采用<%@ include file=""%>方式包含文件时,需要在被包含文件里指定其pageEncoding.

否则无法获取到对应的pageEncoding,则tomcat采用iso8850-1来读取被包含文件,被包含文件含有中文时就会出现乱码。但如果include的是一个html,txt等静态文件就比较麻烦。现在测试出一个方案就是在web.xml里添加:

<jsp-config>
   <jsp-property-group>  
       <display-name>JSPConfiguration</display-name>  
       <url-pattern>*.html</url-pattern>  
       <page-encoding>UTF-8</page-encoding>  
    </jsp-property-group>
</jsp-config>

就可以了。指定以html结尾的文件都以utf-8编码去读取。


<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <!-- ============ 颜色基准 ============ --> <!-- ★ 新增说明详情:暗夜模式颜色与亮色保持语义一致,只调色值 --> <Color x:Key="WindowBgColor">#FF1E1E1E</Color> <Color x:Key="AltBgColor">#FF262626</Color> <Color x:Key="CardBorderColor">#FF383838</Color> <Color x:Key="AccentColor">#FF64B5F6</Color> <Color x:Key="AccentHoverColor">#FF8ABCF7</Color> <Color x:Key="TextFgColor">#FFF2F2F2</Color> <Color x:Key="SubTextFgColor">#FFB0B0B0</Color> <Color x:Key="DisabledFgColor">#FF707070</Color> <Color x:Key="DisabledBgColor">#FF3A3A3A</Color> <Color x:Key="HoverBgColor">#332196F3</Color> <!-- 半透明 Hover --> <Color x:Key="SelectedBgColor">#552196F3</Color> <!-- 半透明选中 --> <Color x:Key="SelectedFgColor">#FFFFFFFF</Color> <Color x:Key="ScrollBarThumbColor">#FF5E5E5E</Color> <!-- ============ 刷子封装 ============ --> <SolidColorBrush x:Key="WindowBgBrush" Color="{StaticResource WindowBgColor}" /> <SolidColorBrush x:Key="AltBgBrush" Color="{StaticResource AltBgColor}" /> <SolidColorBrush x:Key="CardBorderBrush"Color="{StaticResource CardBorderColor}" /> <SolidColorBrush x:Key="AccentBrush" Color="{StaticResource AccentColor}" /> <SolidColorBrush x:Key="AccentHoverBrush" Color="{StaticResource AccentHoverColor}" /> <SolidColorBrush x:Key="TextFgBrush" Color="{StaticResource TextFgColor}" /> <SolidColorBrush x:Key="SubTextFgBrush" Color="{StaticResource SubTextFgColor}" /> <SolidColorBrush x:Key="DisabledFgBrush"Color="{StaticResource DisabledFgColor}" /> <SolidColorBrush x:Key="DisabledBgBrush"Color="{StaticResource DisabledBgColor}" /> <SolidColorBrush x:Key="HoverBgBrush" Color="{StaticResource HoverBgColor}" /> <SolidColorBrush x:Key="SelectedBgBrush"Color="{StaticResource SelectedBgColor}" /> <SolidColorBrush x:Key="SelectedFgBrush"Color="{StaticResource SelectedFgColor}" /> <SolidColorBrush x:Key="ScrollBarThumbBrush" Color="{StaticResource ScrollBarThumbColor}" /> <!-- ============ 全局字体大小保持一致 ============ --> <sys:Double x:Key="FontSizeBase" xmlns:sys="clr-namespace:System;assembly=mscorlib">13</sys:Double> <!-- ============ Window ========= --> <Style TargetType="Window"> <Setter Property="Background" Value="{DynamicResource WindowBgBrush}"/> <Setter Property="Foreground" Value="{DynamicResource TextFgBrush}"/> <Setter Property="FontSize" Value="{DynamicResource FontSizeBase}"/> </Style> <!-- ============ Panel / Border / DockPanel / Grid 默认背景 ============ --> <Style TargetType="{x:Type Panel}"> <Setter Property="Background" Value="{DynamicResource WindowBgBrush}"/> </Style> <Style TargetType="Border"> <Setter Property="Background" Value="{DynamicResource AltBgBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource CardBorderBrush}"/> <Setter Property="BorderThickness" Value="1"/> </Style> <!-- ============ TextBlock ============ --> <Style TargetType="TextBlock"> <Setter Property="Foreground" Value="{DynamicResource TextFgBrush}"/> </Style> <!-- ============ Button ============ --> <Style TargetType="Button"> <Setter Property="Background" Value="{DynamicResource AccentBrush}"/> <Setter Property="Foreground" Value="White"/> <Setter Property="BorderBrush" Value="{DynamicResource AccentBrush}"/> <Setter Property="BorderThickness" Value="1"/> <Setter Property="Padding" Value="6,2"/> <Setter Property="Cursor" Value="Hand"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3"> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" RecognizesAccessKey="True"/> </Border> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="{DynamicResource AccentHoverBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource AccentHoverBrush}"/> </Trigger> <Trigger Property="IsPressed" Value="True"> <Setter Property="Background" Value="{DynamicResource AccentHoverBrush}"/> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter Property="Background" Value="{DynamicResource DisabledBgBrush}"/> <Setter Property="Foreground" Value="{DynamicResource DisabledFgBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource DisabledBgBrush}"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> <!-- ============ ToggleButton / CheckBox / RadioButton 统一色调 ============ --> <Style TargetType="ToggleButton" BasedOn="{StaticResource {x:Type Button}}"/> <Style TargetType="CheckBox"> <Setter Property="Foreground" Value="{DynamicResource TextFgBrush}"/> </Style> <Style TargetType="RadioButton" BasedOn="{StaticResource {x:Type CheckBox}}"/> <!-- ============ TextBox / ComboBox / Slider ============ --> <Style TargetType="TextBox"> <Setter Property="Foreground" Value="{DynamicResource TextFgBrush}"/> <Setter Property="Background" Value="{DynamicResource AltBgBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource CardBorderBrush}"/> </Style> <Style TargetType="ComboBox" BasedOn="{StaticResource {x:Type TextBox}}"/> <Style TargetType="Slider"> <Setter Property="Foreground" Value="{DynamicResource AccentBrush}"/> </Style> <!-- ============ ProgressBar ============ --> <Style TargetType="ProgressBar"> <Setter Property="Foreground" Value="{DynamicResource AccentBrush}"/> </Style> <!-- ============ ListBox / TreeView 行高亮 ============ --> <Style TargetType="ListBoxItem"> <Setter Property="Foreground" Value="{DynamicResource TextFgBrush}"/> <Setter Property="Background" Value="Transparent"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ListBoxItem"> <Border x:Name="Bd" Background="{TemplateBinding Background}"> <ContentPresenter/> </Border> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter TargetName="Bd" Property="Background" Value="{DynamicResource HoverBgBrush}"/> </Trigger> <Trigger Property="IsSelected" Value="True"> <Setter TargetName="Bd" Property="Background" Value="{DynamicResource SelectedBgBrush}"/> <Setter Property="Foreground" Value="{DynamicResource SelectedFgBrush}"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style TargetType="TreeViewItem"> <Setter Property="Foreground" Value="{DynamicResource TextFgBrush}"/> <Setter Property="Background" Value="Transparent"/> </Style> <!-- ============ ScrollBar ============ --> <Style TargetType="ScrollBar"> <Setter Property="Background" Value="{DynamicResource AltBgBrush}"/> <Setter Property="Width" Value="12"/> </Style> <Style TargetType="Thumb"> <Setter Property="Background" Value="{DynamicResource ScrollBarThumbBrush}"/> </Style> <!-- ============ ContextMenu / MenuItem ============ --> <Style TargetType="ContextMenu"> <Setter Property="Background" Value="{DynamicResource AltBgBrush}"/> <Setter Property="Foreground" Value="{DynamicResource TextFgBrush}"/> </Style> <Style TargetType="MenuItem"> <Setter Property="Foreground" Value="{DynamicResource TextFgBrush}"/> <Style.Triggers> <Trigger Property="IsHighlighted" Value="True"> <Setter Property="Background" Value="{DynamicResource HoverBgBrush}"/> </Trigger> </Style.Triggers> </Style> </ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <!-- ============ 颜色基准 ============ --> <!-- ★ 新增说明详情:基础颜色,便于后续统一调整 --> <Color x:Key="WindowBgColor">#FFF7F7F7</Color> <!-- 整体背景 --> <Color x:Key="AltBgColor">#FFFFFFFF</Color> <!-- 卡片 / ToolBar 等 --> <Color x:Key="CardBorderColor">#FFE0E0E0</Color> <!-- 卡片边框 --> <Color x:Key="AccentColor">#FF2196F3</Color> <!-- 主高亮色 --> <Color x:Key="AccentHoverColor">#FF42A5F5</Color> <!-- 鼠标悬停高亮 --> <Color x:Key="TextFgColor">#FF212121</Color> <!-- 正文字体 --> <Color x:Key="SubTextFgColor">#FF555555</Color> <!-- 辅助说明文字 --> <Color x:Key="DisabledFgColor">#FF9E9E9E</Color> <!-- 失效文字 --> <Color x:Key="DisabledBgColor">#FFE0E0E0</Color> <!-- 失效背景 --> <Color x:Key="HoverBgColor">#FFE8F1FF</Color> <!-- Hover 行背景 --> <Color x:Key="SelectedBgColor">#FFCCE5FF</Color> <!-- 选中行背景 --> <Color x:Key="SelectedFgColor">#FF000000</Color> <!-- 选中文本 --> <Color x:Key="ScrollBarThumbColor">#FFC0C0C0</Color> <!-- 滚动条滑块 --> <!-- ============ 刷子封装 ============ --> <!-- ★ 新增说明详情:全部用 SolidColorBrush 并标记 Freeze --> <SolidColorBrush x:Key="WindowBgBrush" Color="{StaticResource WindowBgColor}" /> <SolidColorBrush x:Key="AltBgBrush" Color="{StaticResource AltBgColor}" /> <SolidColorBrush x:Key="CardBorderBrush"Color="{StaticResource CardBorderColor}" /> <SolidColorBrush x:Key="AccentBrush" Color="{StaticResource AccentColor}" /> <SolidColorBrush x:Key="AccentHoverBrush" Color="{StaticResource AccentHoverColor}" /> <SolidColorBrush x:Key="TextFgBrush" Color="{StaticResource TextFgColor}" /> <SolidColorBrush x:Key="SubTextFgBrush" Color="{StaticResource SubTextFgColor}" /> <SolidColorBrush x:Key="DisabledFgBrush"Color="{StaticResource DisabledFgColor}" /> <SolidColorBrush x:Key="DisabledBgBrush"Color="{StaticResource DisabledBgColor}" /> <SolidColorBrush x:Key="HoverBgBrush" Color="{StaticResource HoverBgColor}" /> <SolidColorBrush x:Key="SelectedBgBrush"Color="{StaticResource SelectedBgColor}" /> <SolidColorBrush x:Key="SelectedFgBrush"Color="{StaticResource SelectedFgColor}" /> <SolidColorBrush x:Key="ScrollBarThumbBrush" Color="{StaticResource ScrollBarThumbColor}" /> <!-- ============ 全局字体大小 ============ --> <sys:Double x:Key="FontSizeBase" xmlns:sys="clr-namespace:System;assembly=mscorlib">13</sys:Double> <!-- ============ Window ========= --> <!-- ★ 新增说明详情:所有窗口默认背景/前景 --> <Style TargetType="Window"> <Setter Property="Background" Value="{DynamicResource WindowBgBrush}"/> <Setter Property="Foreground" Value="{DynamicResource TextFgBrush}"/> <Setter Property="FontSize" Value="{DynamicResource FontSizeBase}"/> </Style> <!-- ============ Panel / Border / DockPanel / Grid 默认背景 ============ --> <Style TargetType="{x:Type Panel}"> <Setter Property="Background" Value="{DynamicResource WindowBgBrush}"/> </Style> <Style TargetType="Border"> <Setter Property="Background" Value="{DynamicResource AltBgBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource CardBorderBrush}"/> <Setter Property="BorderThickness" Value="1"/> </Style> <!-- ============ TextBlock ============ --> <Style TargetType="TextBlock"> <Setter Property="Foreground" Value="{DynamicResource TextFgBrush}"/> </Style> <!-- ============ Button ============ --> <Style TargetType="Button"> <Setter Property="Background" Value="{DynamicResource AccentBrush}"/> <Setter Property="Foreground" Value="White"/> <Setter Property="BorderBrush" Value="{DynamicResource AccentBrush}"/> <Setter Property="BorderThickness" Value="1"/> <Setter Property="Padding" Value="6,2"/> <Setter Property="Cursor" Value="Hand"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3"> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" RecognizesAccessKey="True"/> </Border> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="{DynamicResource AccentHoverBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource AccentHoverBrush}"/> </Trigger> <Trigger Property="IsPressed" Value="True"> <Setter Property="Background" Value="{DynamicResource AccentHoverBrush}"/> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter Property="Background" Value="{DynamicResource DisabledBgBrush}"/> <Setter Property="Foreground" Value="{DynamicResource DisabledFgBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource DisabledBgBrush}"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> <!-- ============ ToggleButton / CheckBox / RadioButton 统一色调 ============ --> <Style TargetType="ToggleButton" BasedOn="{StaticResource {x:Type Button}}"/> <Style TargetType="CheckBox"> <Setter Property="Foreground" Value="{DynamicResource TextFgBrush}"/> </Style> <Style TargetType="RadioButton" BasedOn="{StaticResource {x:Type CheckBox}}"/> <!-- ============ TextBox / ComboBox / Slider ============ --> <Style TargetType="TextBox"> <Setter Property="Foreground" Value="{DynamicResource TextFgBrush}"/> <Setter Property="Background" Value="{DynamicResource AltBgBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource CardBorderBrush}"/> </Style> <Style TargetType="ComboBox" BasedOn="{StaticResource {x:Type TextBox}}"/> <Style TargetType="Slider"> <Setter Property="Foreground" Value="{DynamicResource AccentBrush}"/> </Style> <!-- ============ ProgressBar ============ --> <Style TargetType="ProgressBar"> <Setter Property="Foreground" Value="{DynamicResource AccentBrush}"/> </Style> <!-- ============ ListBox / TreeView 行高亮 ============ --> <Style TargetType="ListBoxItem"> <Setter Property="Foreground" Value="{DynamicResource TextFgBrush}"/> <Setter Property="Background" Value="Transparent"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ListBoxItem"> <Border x:Name="Bd" Background="{TemplateBinding Background}"> <ContentPresenter/> </Border> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter TargetName="Bd" Property="Background" Value="{DynamicResource HoverBgBrush}"/> </Trigger> <Trigger Property="IsSelected" Value="True"> <Setter TargetName="Bd" Property="Background" Value="{DynamicResource SelectedBgBrush}"/> <Setter Property="Foreground" Value="{DynamicResource SelectedFgBrush}"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> <!-- TreeViewItem 同理 --> <Style TargetType="TreeViewItem"> <Setter Property="Foreground" Value="{DynamicResource TextFgBrush}"/> <Setter Property="Background" Value="Transparent"/> </Style> <!-- ============ ScrollBar ============ --> <Style TargetType="ScrollBar"> <Setter Property="Background" Value="{DynamicResource AltBgBrush}"/> <Setter Property="Width" Value="12"/> </Style> <Style TargetType="Thumb"> <Setter Property="Background" Value="{DynamicResource ScrollBarThumbBrush}"/> </Style> <!-- ============ ContextMenu / MenuItem ============ --> <Style TargetType="ContextMenu"> <Setter Property="Background" Value="{DynamicResource AltBgBrush}"/> <Setter Property="Foreground" Value="{DynamicResource TextFgBrush}"/> </Style> <Style TargetType="MenuItem"> <Setter Property="Foreground" Value="{DynamicResource TextFgBrush}"/> <Style.Triggers> <Trigger Property="IsHighlighted" Value="True"> <Setter Property="Background" Value="{DynamicResource HoverBgBrush}"/> </Trigger> </Style.Triggers> </Style> </ResourceDictionary>严重性 代码 说明 项目 文件 行 抑制状态 详细信息 错误 XLS0307 “Color”是导致 XML 无效的意外标记。应为空白。 AssetStudio G:\我的程序开发\MyApp\AssetStudio\AssetStudio\Themes\DarkTheme.xaml 26 错误 XLS0307 “Color”是导致 XML 无效的意外标记。应为空白。 AssetStudio G:\我的程序开发\MyApp\AssetStudio\AssetStudio\Themes\DarkTheme.xaml 31 错误 XLS0307 “Color”是导致 XML 无效的意外标记。应为空白。 AssetStudio G:\我的程序开发\MyApp\AssetStudio\AssetStudio\Themes\DarkTheme.xaml 32 错误 XLS0307 “Color”是导致 XML 无效的意外标记。应为空白。 AssetStudio G:\我的程序开发\MyApp\AssetStudio\AssetStudio\Themes\DarkTheme.xaml 34 错误 XLS0307 “Color”是导致 XML 无效的意外标记。应为空白。 AssetStudio G:\我的程序开发\MyApp\AssetStudio\AssetStudio\Themes\DarkTheme.xaml 35 错误 XLS0307 “Color”是导致 XML 无效的意外标记。应为空白。 AssetStudio G:\我的程序开发\MyApp\AssetStudio\AssetStudio\Themes\LightTheme.xaml 38 错误 XLS0307 “Color”是导致 XML 无效的意外标记。应为空白。 AssetStudio G:\我的程序开发\MyApp\AssetStudio\AssetStudio\Themes\LightTheme.xaml 43 错误 XLS0307 “Color”是导致 XML 无效的意外标记。应为空白。 AssetStudio G:\我的程序开发\MyApp\AssetStudio\AssetStudio\Themes\LightTheme.xaml 44 错误 XLS0307 “Color”是导致 XML 无效的意外标记。应为空白。 AssetStudio G:\我的程序开发\MyApp\AssetStudio\AssetStudio\Themes\LightTheme.xaml 46 错误 XLS0307 “Color”是导致 XML 无效的意外标记。应为空白。 AssetStudio G:\我的程序开发\MyApp\AssetStudio\AssetStudio\Themes\LightTheme.xaml 47 错误(活动) MC3000 ““Color”是一个意外标记。应为空格。 第 26 行,位置 45。.XML 无效。 AssetStudio G:\我的程序开发\MyApp\AssetStudio\AssetStudio\Themes\DarkTheme.xaml 26 错误(活动) MC3000 ““Color”是一个意外标记。应为空格。 第 38 行,位置 45。.XML 无效。 AssetStudio G:\我的程序开发\MyApp\AssetStudio\AssetStudio\Themes\LightTheme.xaml 38
最新发布
06-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值