javaweb國際化

根據數據的類型不同,國際化分為2類:靜態數據國際化和動態數據的國際化。

?

靜態數據,包括 “標題”、“用戶名”、“密碼”這樣的文字數據。

動態數據,包括日期、貨幣等可以動態生成的數據。

?

國際化涉及到java.util.Locale和java.util.ResourceBundle類。

?

java.util.Locale

A Locale object represents a specific geographical, political, or cultural region.

Locale對象代表了一定的地理、政治、文化區域。

?

java.util.ResourceBundle

Resource bundles contain locale-specific objects. When your program needs a locale-specific resource, a String for example, your program can load it from the resource bundle that is appropriate for the current user's locale. In this way, you can write program code that is largely independent of the user's locale isolating most, if not all, of the locale-specific information in resource bundles.?

ResouceBundle,由兩個單詞組成Resouce和Bundle,合在一起就是“資源包”的意思。ResouceBundle是包含不同區域(Locale)資源的集合,只要向ResouceBundle提供一個特定的Locale對象,ResouceBundle就會把相應的資源返回給你。

wKiom1d5hMbSGxdUAAAyLcgcnhk020.png

1、靜態數據國際化

?

靜態數據國際化的步驟:

(1).建立資源文件,存儲所有國家顯示的文本的字符串

????a)文件: .properties

????b)命名: ?基礎名_語言簡稱_國家簡稱.properties

????????例如:?msg_zh_CN.properties ? ? 存儲所有中文

????????????msg_en_US.properties ? ?存儲所有英文

(2).程序中獲取

????ResourceBundle類,可以讀取國際化的資源文件!

????Locale類,代表某一區域,用于決定使用哪一個國際化的資源。

?

1.1、Locale的API

static Locale getDefault()????得到JVM中默認的Locale對象

String getCountry()????? ? ?得到國家名稱的簡寫

String getDisplayCountry()????得到國家名稱的全稱

String getLanguage()????? ? 得到當前語言的簡寫

String getDisplayLanguage()????得到語言的全稱

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package?com.rk.i18n.demo;
import?java.util.Locale;
public?class?Demo01
{
????public?static?void?main(String[]?args)
????{
????????//本地化對象:Locale
????????//?封裝語言、國家信息的對象,由java.util提供
//????? Locale?locale?=?Locale.CHINA;
//????? Locale?locale?=?Locale.US;
????????Locale?locale?=?Locale.getDefault();
????????String?country?=?locale.getCountry();
????????String?displayCountry?=?locale.getDisplayCountry();
????????String?language?=?locale.getLanguage();
????????String?displayLanguage?=?locale.getDisplayLanguage();
?????????
????????System.out.println(country);??????????//????? CN???????
????????System.out.println(displayCountry);???//???? 中國???????
????????System.out.println(language);?????????//?????? zh???????
????????System.out.println(displayLanguage);??//????? 中文???????
????}
}

?

1.2、ResourceBundle的API

static ResourceBundle getBundle(String baseName,Locale locale) 獲取ResourceBundle實例

String getString(String key)????根據key獲取資源中的值

?

?

1.3、示例

?

(1)建立properties文件:msg_zh_CN.properties和msg_en_US.properties

msg_zh_CN.properties

1
2
uname=\u59D3\u540D
pwd=\u5BC6\u7801

wKioL1d5jefT6vNlAAALbK1OAno343.png

?

msg_en_US.properties

1
2
uname=User?Name
pwd=Password

(2)代碼獲取

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package?com.rk.i18n.demo;
import?java.util.Locale;
import?java.util.ResourceBundle;
//?國際化?-?靜態數據
public?class?Demo02
{
????public?static?void?main(String[]?args)
????{
????????//?中文語言環境
????????Locale?locale?=?Locale.US;
?????????
????????//?創建工具類對象ResourceBundle
????????ResourceBundle?bundle?=?ResourceBundle.getBundle("com.rk.i18n.demo.msg",?locale);
?????????
????????//?根據key獲取配置文件中的值
????????String?uname?=?bundle.getString("uname");
????????String?pwd?=?bundle.getString("pwd");
?????????
????????//輸出
????????System.out.println(uname);
????????System.out.println(pwd);
????}
}

?

1.4、關于ResourceBundle的資源文件properties

文件命名:基礎名、語言簡稱

Resource bundles belong to families whose members share a common base name, but whose names also have additional components that identify their locales. For example, the base name of a family of resource bundles might be "MyResources". ?The family can then provide as many locale-specific members as needed, for example a German one named "MyResources_de".?

?

文件命名:國家簡稱

If there are different resources for different countries, you can make specializations: for example, "MyResources_de_CH" contains objects for the German language (de) in Switzerland (CH). If you want to only modify some of the resources in the specialization, you can do so.?

?

文件命名:默認的Resource Bundle

The family should have a default resource bundle which simply has the same name as its family - "MyResources" - and will be used as the bundle of last resort if a specific locale is not supported.

?

文件內容:屬于同一個family的resource bundle要包含相同的items內容。

Each resource bundle in a family contains the same items, but the items have been translated for the locale represented by that resource bundle. For example, both "MyResources" and "MyResources_de" may have a String that's used on a button for canceling operations. In "MyResources" the String may contain "Cancel" and in "MyResources_de" it may contain "Abbrechen".?

?

Java代碼:獲取Resource Bundle

When your program needs a locale-specific object, it loads the ResourceBundle class using the getBundle method:?

?

?ResourceBundle myResources = ResourceBundle.getBundle("MyResources", currentLocale);

?

?

2、動態數據國際化

動態國際化則主要涉及到數字、貨幣、百分比和日期

例如:

????中文:1987-09-19 ? ¥1000

????英文: Sep/09 1987 ?$100

?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package?com.rk.i18n.demo;
import?java.text.DateFormat;
import?java.text.NumberFormat;
import?java.text.ParseException;
import?java.util.Date;
import?java.util.Locale;
import?org.junit.Test;
public?class?Demo03
{
????//?國際化?-?動態文本?-?0.?概述
????public?void?testI18N()
????{
????????//?國際化貨幣
????????NumberFormat.getCurrencyInstance();
????????//?國際化數字
????????NumberFormat.getNumberInstance();
????????//?國際化百分比
????????NumberFormat.getPercentInstance();
????????//?國際化日期
????????//?DateFormat.getDateTimeInstance(dateStyle,?timeStyle,?aLocale)
????}
????//?國際化?-?動態文本?-?1.?國際化貨幣
????@Test
????public?void?testI18NCurrency()
????{
????????//?模擬語言環境
????????Locale?locale?=?Locale.CHINA;
????????//?數據準備
????????double?number?=?100;
????????//?工具類
????????NumberFormat?nf?=?NumberFormat.getCurrencyInstance(locale);
????????//?國際化貨幣
????????String?str?=?nf.format(number);
????????//?輸出
????????System.out.println(str);
????}
?????
????//面試題:??代碼計算:??$100?*?10??
????@Test
????public?void?testCurrency()?throws?ParseException
????{
????????String?str?=?"$100";
????????int?num?=?10;
?????????
????????//?1.?分析str值是哪一國家的貨幣
????????Locale?locale?=?Locale.US;
?????????
????????//?2.?國際化工具類
????????NumberFormat?nf?=?NumberFormat.getCurrencyInstance(locale);
?????????
????????//?3.?解析str
????????Number?number?=?nf.parse(str);
?????????
????????//4.進行計算
????????int?value?=?number.intValue()?*?num;
????????//5.格式化輸出
????????str?=?nf.format(value);
????????System.out.println(str);
????}
?????
????//?國際化?-?動態文本?-?2.?國際化數值
????@Test
????public?void?testI18NNumber()
????{
????????Locale?locale?=?Locale.CHINA;
????????NumberFormat?nf?=?NumberFormat.getNumberInstance(locale);
????????String?str?=?nf.format(1000000000);
????????System.out.println(str);
????}
?????
????//?國際化?-?動態文本?-?3.?國際化百分比
????@Test
????public?void?testI18NPercent()
????{
????????Locale?locale?=?Locale.CHINA;
????????NumberFormat?nf?=?NumberFormat.getPercentInstance(locale);
????????String?str?=?nf.format(0.325);
????????System.out.println(str);
????}
?????
????//?國際化?-?動態文本?-?4.?國際化日期
????/*
?????*?日期
?????*??? ??FULL???2015年3月4日?星期三
?????*??? ??LONG???2015年3月4日
?????*??? ??FULL???2015年3月4日?星期三
?????*????MEDIUM?2015-3-4
?????*????SHORT??15-3-4
?????*????
?????*?時間
?????*??? ??FULL???下午04時31分59秒?CST
?????*??? ??LONG???下午04時32分37秒
?????*????MEDIUM?16:33:00
?????*????SHORT??下午4:33
?????*????
?????*?
?????*/
????@Test
????public?void?testI18NDate()
????{
????????int?dateStyle?=?DateFormat.FULL;
????????int?timeStyle?=?DateFormat.FULL;
????????Locale?locale?=?Locale.CHINA;
????????DateFormat?df?=?DateFormat.getDateTimeInstance(dateStyle,?timeStyle,?locale);
????????String?date?=?df.format(new?Date());
????????System.out.println(date);
????}
?????
????//?面試2:?請將時間值:09-11-28?上午10時25分39秒?CST,反向解析成一個date對象。
????@Test
????public?void?testDate()?throws?ParseException
????{
????????String?str?=?"09-11-28?上午10時25分39秒?CST";
?????????
????????int?dateStyle?=?DateFormat.SHORT;
????????int?timeStyle?=?DateFormat.FULL;
????????Locale?locale?=?Locale.CHINA;
????????//?創建DateFormat工具類,國際化日期
????????DateFormat?df?=?DateFormat.getDateTimeInstance(dateStyle,?timeStyle,?locale);
????????Date?date?=?df.parse(str);
????????System.out.println(date);
????}
}

?

?

?

3、JSP頁面國際化

?

數值,貨幣,時間,日期等數據由于可能在程序運行時動態產生,所以無法像文字一樣簡單地將它們從應用程序中分離出來,而是需要特殊處理,有的Java培訓機構講的不錯。Java 中提供了解決這些問題的 API 類(位于 java.util 包和 java.text 包中)

?

3.1、準備工作:建立properties資源

建立2個properties文件:message_en_US.properties和message_zh_CN.properties。

?

message_zh_CN.properties

1
2
3
4
title=\u4F60\u597D\uFF0C\u8BF7\u767B\u5F55
uname=\u7528\u6237\u540D
pwd=\u5BC6\u7801
submit=\u63D0\u4EA4

wKiom1d5j8aArKdIAAAOCpAj0R8612.png

message_en_US.properties

1
2
3
4
title=Plean?Log?In
uname=User?Name
pwd=Password
submit=Submit\!

?

3.2、使用JSP腳本進行國際化

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<%@?page?language="java"?import="java.util.*"?pageEncoding="UTF-8"%>
<!DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.01?Transitional//EN">
<html>
??<head>
????<%
????????ResourceBundle?bundle?=?ResourceBundle.getBundle("com.rk.i18n.resource.message",?request.getLocale());
????%>
????<title><%=bundle.getString("title")?%></title>
????<meta?http-equiv="pragma"?content="no-cache">
????<meta?http-equiv="cache-control"?content="no-cache">
????<meta?http-equiv="expires"?content="0">????
??</head>
???
??<body>
????<table?border="1">
????????<tr>
????????????<td><%=bundle.getString("uname")?%></td>
????????????<td><input?type="text"?name="uname"/></td>
????????</tr>
????????<tr>
????????????<td><%=bundle.getString("pwd")?%></td>
????????????<td><input?type="password"?name="pwd"/></td>
????????</tr>
????????<tr>
????????????<td></td>
????????????<td><input?type="submit"?value="<%=bundle.getString("submit")?%>"/></td>
????????</tr>????
????</table>
??</body>
</html>

?

3.3、使用JSTL進行國際化

?

JSTL標簽:

????核心標簽庫

????國際化與格式化標簽庫

????數據庫標簽庫(沒用)

????函數庫

????<fmt:setLocale value=""/> ? ? ? ?設置本地化對象

????<fmt:setBundle basename=""/> ? ? 設置工具類

????<fmt:message></fmt:message> ? ? 顯示國際化文本

????格式化數值:<fmt:formatNumber pattern="#.##" value="100.99"></fmt:formatNumber>

????格式化日期:<fmt:formatDate pattern="yyyy-MM-dd" value="${date}"/>

?

需要注意的一點是:HttpServletRequest有一個方法是getLocale(),可以獲取當前request中的Locale信息,在EL表達式中可以使用${pageContext.request.locale}獲取

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<%@?page?language="java"?import="java.util.*"?pageEncoding="UTF-8"%>
<%--引入jstl國際化與格式化標簽庫?--%>
<%@taglib?uri="http://java.sun.com/jsp/jstl/fmt"?prefix="fmt"%>
<!DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.01?Transitional//EN">
<html>
??<head>
????<!--?一、設置本地化對象?-->
????<fmt:setLocale?value="${pageContext.request.locale?}"/>
????<!--?二、設置工具類?-->
????<fmt:setBundle?basename="com.rk.i18n.resource.message"?var="msg"/>
????<title><fmt:message?bundle="${msg?}"?key="title"></fmt:message></title>
????<meta?http-equiv="pragma"?content="no-cache">
????<meta?http-equiv="cache-control"?content="no-cache">
????<meta?http-equiv="expires"?content="0">????
??</head>
???
??<body>
????<table?border="1">
????????<tr>
????????????<td><fmt:message?bundle="${msg?}"?key="uname"></fmt:message></td>
????????????<td><input?type="text"?name="uname"/></td>
????????</tr>
????????<tr>
????????????<td><fmt:message?bundle="${msg?}"?key="pwd"></fmt:message></td>
????????????<td><input?type="password"?name="pwd"/></td>
????????</tr>
????????<tr>
????????????<td></td>
????????????<td><input?type="submit"?value="<fmt:message?bundle="${msg?}"?key="submit"></fmt:message>"/></td>
????????</tr>????
????</table>
??</body>
</html>

?

格式化數值和日期

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<%@?page?language="java"?import="java.util.*"?pageEncoding="UTF-8"%>
<%@taglib?uri="http://java.sun.com/jsp/jstl/fmt"?prefix="fmt"?%>
<!DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.01?Transitional//EN">
<html>
??<head>
????<title>格式化</title>
????<meta?http-equiv="pragma"?content="no-cache">
????<meta?http-equiv="cache-control"?content="no-cache">
????<meta?http-equiv="expires"?content="0">????
??<body>
??????<!--?
??????????格式化金額?
??????????????格式:?0.00???保留2為小數,會自動補0
???????????????????#.##??保留2為小數,不自動補0
??????-->
????<fmt:formatNumber?pattern="0.00"?value="100"?></fmt:formatNumber>?<br>
????<fmt:formatNumber?pattern="#.##"?value="100"?></fmt:formatNumber>??<br>
????<fmt:formatDate?pattern="yyyyMMdd"?value="<%=new?Date()?%>"/>?<br>
????<%
????????request.setAttribute("date",?new?Date());
????%>
????<fmt:formatDate?pattern="yyyy-MM-dd"??value="${date?}"/>?<br>
??</body>
</html>

轉載于:https://www.cnblogs.com/plan123/p/5639803.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/372714.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/372714.shtml
英文地址,請注明出處:http://en.pswp.cn/news/372714.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

20145335郝昊《網絡攻防》Bof逆向基礎——ShellCode注入與執行

20145335郝昊《網絡攻防》Bof逆向基礎——ShellCode注入與執行 實驗原理 關于ShellCode&#xff1a;ShellCode是一段代碼&#xff0c;作為數據發送給受攻擊服務器&#xff0c;是溢出程序和蠕蟲病毒的核心&#xff0c;一般可以獲取權限。我們將代碼存儲到對方的堆棧中&#xff0…

Java枚舉益智游戲

假設我們有以下代碼&#xff1a; enum Case {CASE_ONE,CASE_TWO,CASE_THREE;private static final int counter;private int valueDependsOnCounter;static {int sum 0;for(int i 0; i<10; i) {sum i;}counter sum;} Case() {this.valueDependsOnCounter counter*counte…

jp在java中無法編譯_JPanal上加圖片的問題!

JPanal上加圖片的問題&#xff01;import java.awt.BorderLayout;import java.awt.Dimension;import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.*;import java.awt.*;public class Frame1 extends JFrame {JPanel contentPane;JLabel jLabel1 new JLa…

玩轉Android之加速度傳感器的使用,模仿微信搖一搖

Android系統帶的傳感器有很多種&#xff0c;最常見的莫過于微信的搖一搖了&#xff0c;那么今天我們就來看看Anroid中傳感器的使用&#xff0c;做一個類似于微信搖一搖的效果。 OK ,廢話不多說&#xff0c;我們就先來看看效果圖吧&#xff1a; 當我搖動手機的時候這里的動畫效果…

圖像

背景圖案的設置 將圖片插入到網頁中去 用圖像作為超鏈接 使用工具建立地圖索引 切片索引 為網站添加圖標 5.1 背景圖案的設置&#xff08;背景不占位置&#xff0c;不影響文本的輸入&#xff09; 格式&#xff1a;<body background"URL"> 5.2 將圖片插入…

Maven構建依賴項

熟悉發行版和快照依賴項的Maven和Gradle用戶可能不了解TeamCity快照依賴項&#xff0c;或者認為他們與Maven相關&#xff08;這是不正確的&#xff09;。 熟悉工件和快照依賴關系的TeamCity用戶可能不知道&#xff0c;除了TeamCity提供的插件之外&#xff0c;添加Artifactory插…

Java兩種設計模式_23種設計模式(11)java策略模式

23種設計模式第四篇&#xff1a;java策略模式定義&#xff1a;定義一組算法&#xff0c;將每個算法都封裝起來&#xff0c;并且使他們之間可以互換。類型&#xff1a;行為類模式類圖&#xff1a;策略模式是對算法的封裝&#xff0c;把一系列的算法分別封裝到對應的類中&#xf…

Problem E: 平面上的點——Point類 (II)

Description 在數學上&#xff0c;平面直角坐標系上的點用X軸和Y軸上的兩個坐標值唯一確定。現在我們封裝一個“Point類”來實現平面上的點的操作。 根據“append.cc”&#xff0c;完成Point類的構造方法和show()方法&#xff0c;輸出各Point對象的構造和析構次序。 接口描述&a…

MFC 控件RadioButton和CheckBox區別

1. 單個RadioButton在選中后&#xff0c;通過點擊無法變為未選中 單個CheckBox在選中后&#xff0c;通過點擊可以變為未選中 2. 一組RadioButton&#xff0c;只能同時選中一個 一組CheckBox&#xff0c;能同時選中多個 3. RadioButton在大部分UI框架中默認都以圓形表示 CheckBo…

什么是ActiveMQ?

盡管Active MQ網站已經對ActiveMQ進行了詳盡的介紹&#xff0c;但我想在其定義中添加更多上下文。 從ActiveMQ項目的網站上&#xff1a; “ ActiveMQ是JMS 1.1的開源實現&#xff0c;是J2EE 1.4規范的一部分。” 這是我的看法&#xff1a;ActiveMQ是一種開源消息傳遞軟件&…

字符串倒著輸出java_Java 輸出反轉字符串

Java 輸出反轉字符串public class Test {public static void main(String args[]){try{// 獲取鍵盤輸入的字符串BufferReader f new BufferReader(new inputStreamReader(System.in));String str f.readline();for (int i str.length() -1 ; i >0 ; i--) {System.out.p…

webpack基礎入門

我相信&#xff0c;有不少的朋友對webpack都有或多或少的了解。網上也有了各種各樣的文章&#xff0c;文章內作者也寫出了不少自己對于webpack這個工具的理解。在我剛剛接觸webpack的時候&#xff0c;老實說&#xff0c;網上大部分的文章我是看不懂的。。webpack里面有很多名詞…

位運算基礎

異或運算的基礎有點忘記了 先介紹一下。。2個數異或 就是對于每一個二進制位進行位運算 具有2個特殊的性質 1、一個數異或本身恒等于0&#xff0c;如5^5恒等于0&#xff1b; 2、一個數異或0恒等于本身&#xff0c;如5^0恒等于5。 3 滿足交換律 1.交換數字這個性質能利用與交換數…

JAXB自定義綁定– Java.util.Date / Spring 3序列化

JaxB可以處理Java.util.Date序列化&#xff0c;但是需要以下格式&#xff1a; “ yyyy-MM-ddTHH&#xff1a;mm&#xff1a;ss ”。 如果需要將日期對象格式化為另一種格式怎么辦&#xff1f; 我有同樣的問題時&#xff0c;我正在同春MVC 3和Jackson JSON處理器 &#xff0c;最…

雙足機器人簡單步態生成

讓機器人行走最簡單的方法是先得到一組步態曲線&#xff0c;即腿部每個關節隨時間運動的角度值。可以在ADAMS或3D Max、Blender等軟件中建立好機構/骨骼模型&#xff0c;設計出腳踝和髖關節的運動曲線&#xff0c;然后進行逆運動學解算&#xff0c;測量每個關節在運動過程中的轉…

重新訪問了訪客模式

訪客模式是面向對象設計中最被高估但又被低估的模式之一。 高估了它&#xff0c;因為它常常被選擇得太快&#xff08; 可能是由建筑宇航員選擇的 &#xff09;&#xff0c;然后以錯誤的方式添加時會膨脹本來非常簡單的設計。 如果您不遵循教科書示例&#xff0c;那么它可能會非…

java web開發技術大_2021年六大javaweb開發主流技術

作為歷史最為悠久的編程語言——java&#xff0c;歷經數十年依然盤踞在編程榜最前面的位置&#xff0c;這與它的技術和應用范圍是分不開的&#xff0c;同時呢&#xff0c;javaweb開發主流技術更是java開發者時時刻刻關注的問題&#xff0c;接下來我們一起分析一下2020年互聯網行…

ASP.NET—013:實現帶控件的彈出層(彈出框)

http://blog.csdn.net/yysyangyangyangshan/article/details/38458169 在頁面中用到彈出新頁面的情況比較多的&#xff0c;一般來說都是使用JS方法showModalDialog("新頁面相對路徑?參數1&參數2",window,"新頁面樣式");然后會新彈出一個模態的page頁。…

運維人員日常工作(轉自老男孩)

1&#xff09;運維人員要謹記的6個字&#xff1a; 運維人員做事需遵循&#xff1a;簡單、易用、高效 &#xff08;2&#xff09;運維人員服務的3大宗旨&#xff1a; 1、企業數據安全保障。 2、7*24小時業務持續提供服務。 3、不斷提升用戶感受、體驗。 &#xff08;3&#xff0…

c# 操作DatatTable

dtTemp.Columns.Add("列名");//增加一列 dtTemp.Columns.Remove("列名");//刪除一列 dtTemp.Columns["舊列名"].ColumnName "新列名";//修改列名 dtTemp.Columns["列名1"].SetOrdinal(dtTemp.Columns["列名2"].O…