可以通过Visual Studio运行时文本模板在您的应用程序在运行时生成文本字符串。 执行应用程序的计算机不必具有 Visual Studio。 运行库模板有时称为"预处理文本模板"由于在编译时,该模板会生成运行时执行的代码。

将现有文件转换为运行时模板:

  • 将该文件的“自定义工具”属性设置为 TextTemplatingFilePreprocessor。【文本模板的自定义工具是TextTemplatingFileGenerator
  • 在文件开头插入下面的行 <#@ template language="C#" #>

运行时模板的tt的内容如下:

 <#@ template language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #> <h2>Sales figures</h2>
<table>
<# foreach (var item in m_data)
// m_data is declared in MyWebPageCode.cs
{ #>
<tr><td> <#= item.Key #> </td>
<td> <#= item.Value #> </td></tr>
<# } // end of foreach
#>
</table>

效果如下:

 // ------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本: 12.0.0.0
//
// 对此文件的更改可能会导致不正确的行为。此外,如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
// ------------------------------------------------------------------------------
namespace Test
{
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System; /// <summary>
/// Class to produce the template output
/// </summary> #line 1 "F:\study\share\Test\html.tt"
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "12.0.0.0")]
public partial class html : htmlBase
{
#line hidden
/// <summary>
/// Create the template output
/// </summary>
public virtual string TransformText()
{
this.Write("<table>\r\n "); #line 7 "F:\study\share\Test\html.tt"
for (int i = 1; i <= 10; i++)
{ #line default
#line hidden
this.Write(" <tr><td>Test name "); #line 9 "F:\study\share\Test\html.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(i)); #line default
#line hidden
this.Write(" </td>\r\n <td>Test value "); #line 10 "F:\study\share\Test\html.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(i * i)); #line default
#line hidden
this.Write(" </td> </tr>\r\n "); #line 11 "F:\study\share\Test\html.tt"
} #line default
#line hidden
this.Write(" </table>");
return this.GenerationEnvironment.ToString();
}
} #line default
#line hidden
#region Base class
/// <summary>
/// Base class for this transformation
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "12.0.0.0")]
public class htmlBase
{
#region Fields
private global::System.Text.StringBuilder generationEnvironmentField;
private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField;
private global::System.Collections.Generic.List<int> indentLengthsField;
private string currentIndentField = "";
private bool endsWithNewline;
private global::System.Collections.Generic.IDictionary<string, object> sessionField;
#endregion
#region Properties
/// <summary>
/// The string builder that generation-time code is using to assemble generated output
/// </summary>
protected System.Text.StringBuilder GenerationEnvironment
{
get
{
if ((this.generationEnvironmentField == null))
{
this.generationEnvironmentField = new global::System.Text.StringBuilder();
}
return this.generationEnvironmentField;
}
set
{
this.generationEnvironmentField = value;
}
}
/// <summary>
/// The error collection for the generation process
/// </summary>
public System.CodeDom.Compiler.CompilerErrorCollection Errors
{
get
{
if ((this.errorsField == null))
{
this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection();
}
return this.errorsField;
}
}
/// <summary>
/// A list of the lengths of each indent that was added with PushIndent
/// </summary>
private System.Collections.Generic.List<int> indentLengths
{
get
{
if ((this.indentLengthsField == null))
{
this.indentLengthsField = new global::System.Collections.Generic.List<int>();
}
return this.indentLengthsField;
}
}
/// <summary>
/// Gets the current indent we use when adding lines to the output
/// </summary>
public string CurrentIndent
{
get
{
return this.currentIndentField;
}
}
/// <summary>
/// Current transformation session
/// </summary>
public virtual global::System.Collections.Generic.IDictionary<string, object> Session
{
get
{
return this.sessionField;
}
set
{
this.sessionField = value;
}
}
#endregion
#region Transform-time helpers
/// <summary>
/// Write text directly into the generated output
/// </summary>
public void Write(string textToAppend)
{
if (string.IsNullOrEmpty(textToAppend))
{
return;
}
// If we're starting off, or if the previous text ended with a newline,
// we have to append the current indent first.
if (((this.GenerationEnvironment.Length == 0)
|| this.endsWithNewline))
{
this.GenerationEnvironment.Append(this.currentIndentField);
this.endsWithNewline = false;
}
// Check if the current text ends with a newline
if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture))
{
this.endsWithNewline = true;
}
// This is an optimization. If the current indent is "", then we don't have to do any
// of the more complex stuff further down.
if ((this.currentIndentField.Length == 0))
{
this.GenerationEnvironment.Append(textToAppend);
return;
}
// Everywhere there is a newline in the text, add an indent after it
textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField));
// If the text ends with a newline, then we should strip off the indent added at the very end
// because the appropriate indent will be added when the next time Write() is called
if (this.endsWithNewline)
{
this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length));
}
else
{
this.GenerationEnvironment.Append(textToAppend);
}
}
/// <summary>
/// Write text directly into the generated output
/// </summary>
public void WriteLine(string textToAppend)
{
this.Write(textToAppend);
this.GenerationEnvironment.AppendLine();
this.endsWithNewline = true;
}
/// <summary>
/// Write formatted text directly into the generated output
/// </summary>
public void Write(string format, params object[] args)
{
this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args));
}
/// <summary>
/// Write formatted text directly into the generated output
/// </summary>
public void WriteLine(string format, params object[] args)
{
this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args));
}
/// <summary>
/// Raise an error
/// </summary>
public void Error(string message)
{
System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError();
error.ErrorText = message;
this.Errors.Add(error);
}
/// <summary>
/// Raise a warning
/// </summary>
public void Warning(string message)
{
System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError();
error.ErrorText = message;
error.IsWarning = true;
this.Errors.Add(error);
}
/// <summary>
/// Increase the indent
/// </summary>
public void PushIndent(string indent)
{
if ((indent == null))
{
throw new global::System.ArgumentNullException("indent");
}
this.currentIndentField = (this.currentIndentField + indent);
this.indentLengths.Add(indent.Length);
}
/// <summary>
/// Remove the last indent that was added with PushIndent
/// </summary>
public string PopIndent()
{
string returnValue = "";
if ((this.indentLengths.Count > 0))
{
int indentLength = this.indentLengths[(this.indentLengths.Count - 1)];
this.indentLengths.RemoveAt((this.indentLengths.Count - 1));
if ((indentLength > 0))
{
returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength));
this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength));
}
}
return returnValue;
}
/// <summary>
/// Remove any indentation
/// </summary>
public void ClearIndent()
{
this.indentLengths.Clear();
this.currentIndentField = "";
}
#endregion
#region ToString Helpers
/// <summary>
/// Utility class to produce culture-oriented representation of an object as a string.
/// </summary>
public class ToStringInstanceHelper
{
private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture;
/// <summary>
/// Gets or sets format provider to be used by ToStringWithCulture method.
/// </summary>
public System.IFormatProvider FormatProvider
{
get
{
return this.formatProviderField ;
}
set
{
if ((value != null))
{
this.formatProviderField = value;
}
}
}
/// <summary>
/// This is called from the compile/run appdomain to convert objects within an expression block to a string
/// </summary>
public string ToStringWithCulture(object objectToConvert)
{
if ((objectToConvert == null))
{
throw new global::System.ArgumentNullException("objectToConvert");
}
System.Type t = objectToConvert.GetType();
System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] {
typeof(System.IFormatProvider)});
if ((method == null))
{
return objectToConvert.ToString();
}
else
{
return ((string)(method.Invoke(objectToConvert, new object[] {
this.formatProviderField })));
}
}
}
private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper();
/// <summary>
/// Helper to produce culture-oriented representation of an object as a string
/// </summary>
public ToStringInstanceHelper ToStringHelper
{
get
{
return this.toStringHelperField;
}
}
#endregion
}
#endregion
}
 class Program
{
static void Main(string[] args)
{
html html = new html();
System.IO.File.WriteAllText("outputPage.html", html.TransformText());
Console.ReadKey();
} }
结果: <table>
<tr><td>Test name 1 </td>
<td>Test value 1 </td> </tr>
<tr><td>Test name 2 </td>
<td>Test value 4 </td> </tr>
<tr><td>Test name 3 </td>
<td>Test value 9 </td> </tr>
<tr><td>Test name 4 </td>
<td>Test value 16 </td> </tr>
<tr><td>Test name 5 </td>
<td>Test value 25 </td> </tr>
<tr><td>Test name 6 </td>
<td>Test value 36 </td> </tr>
<tr><td>Test name 7 </td>
<td>Test value 49 </td> </tr>
<tr><td>Test name 8 </td>
<td>Test value 64 </td> </tr>
<tr><td>Test name 9 </td>
<td>Test value 81 </td> </tr>
<tr><td>Test name 10 </td>
<td>Test value 100 </td> </tr>
</table>

若要在特定命名空间中放置已生成的类,请设置文本模板文件的“自定义工具命名空间”属性。

如果希望模板代码引用 .NET 或其他程序集(如 System.Xml.dll),应以常规方式将其添加到项目的“引用”中。

如果要以与 using 语句相同的方式导入命名空间,可以使用 import 指令

<#@ import namespace="System.Xml" #>

如果要在几个模板间共享文本,可以将文本放置在一个单独的文件中,然后在需要这些文本的每个文件中包含这些文本:

<#@include file="CommonHeader.txt" #> 

继承模式:基方法中的片段

  • 基类在类功能块<#+...#>中定义方法
  • 派生类可以调用基类中定义的方法

MyTextTemplate1.tt继承自SharedFragments.tt(生成的类MyTextTemplate1.cs 继承自SharedFragments.cs)

 SharedFragments.tt
<#@ template language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #> <#+
protected void SharedText(int n)
{
#>
Shared Text <#= n #>
<#+
}
// Insert more methods here if required.
#> SharedFragments.cs
// ------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本: 12.0.0.0
//
// 对此文件的更改可能会导致不正确的行为。此外,如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
// ------------------------------------------------------------------------------
namespace Test
{
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System; /// <summary>
/// Class to produce the template output
/// </summary> #line 1 "F:\study\share\Test\SharedFragments.tt"
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "12.0.0.0")]
public partial class SharedFragments : SharedFragmentsBase
{
#line hidden
/// <summary>
/// Create the template output
/// </summary>
public virtual string TransformText()
{
this.Write(" \r\n");
return this.GenerationEnvironment.ToString();
} #line 7 "F:\study\share\Test\SharedFragments.tt" protected void SharedText(int n)
{ #line default
#line hidden #line 10 "F:\study\share\Test\SharedFragments.tt"
this.Write(" Shared Text "); #line default
#line hidden #line 11 "F:\study\share\Test\SharedFragments.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(n)); #line default
#line hidden #line 11 "F:\study\share\Test\SharedFragments.tt"
this.Write("\r\n"); #line default
#line hidden #line 12 "F:\study\share\Test\SharedFragments.tt" }
// Insert more methods here if required. #line default
#line hidden
} #line default
#line hidden
#region Base class
/// <summary>
/// Base class for this transformation
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "12.0.0.0")]
public class SharedFragmentsBase
{
#region Fields
private global::System.Text.StringBuilder generationEnvironmentField;
private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField;
private global::System.Collections.Generic.List<int> indentLengthsField;
private string currentIndentField = "";
private bool endsWithNewline;
private global::System.Collections.Generic.IDictionary<string, object> sessionField;
#endregion
#region Properties
/// <summary>
/// The string builder that generation-time code is using to assemble generated output
/// </summary>
protected System.Text.StringBuilder GenerationEnvironment
{
get
{
if ((this.generationEnvironmentField == null))
{
this.generationEnvironmentField = new global::System.Text.StringBuilder();
}
return this.generationEnvironmentField;
}
set
{
this.generationEnvironmentField = value;
}
}
/// <summary>
/// The error collection for the generation process
/// </summary>
public System.CodeDom.Compiler.CompilerErrorCollection Errors
{
get
{
if ((this.errorsField == null))
{
this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection();
}
return this.errorsField;
}
}
/// <summary>
/// A list of the lengths of each indent that was added with PushIndent
/// </summary>
private System.Collections.Generic.List<int> indentLengths
{
get
{
if ((this.indentLengthsField == null))
{
this.indentLengthsField = new global::System.Collections.Generic.List<int>();
}
return this.indentLengthsField;
}
}
/// <summary>
/// Gets the current indent we use when adding lines to the output
/// </summary>
public string CurrentIndent
{
get
{
return this.currentIndentField;
}
}
/// <summary>
/// Current transformation session
/// </summary>
public virtual global::System.Collections.Generic.IDictionary<string, object> Session
{
get
{
return this.sessionField;
}
set
{
this.sessionField = value;
}
}
#endregion
#region Transform-time helpers
/// <summary>
/// Write text directly into the generated output
/// </summary>
public void Write(string textToAppend)
{
if (string.IsNullOrEmpty(textToAppend))
{
return;
}
// If we're starting off, or if the previous text ended with a newline,
// we have to append the current indent first.
if (((this.GenerationEnvironment.Length == )
|| this.endsWithNewline))
{
this.GenerationEnvironment.Append(this.currentIndentField);
this.endsWithNewline = false;
}
// Check if the current text ends with a newline
if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture))
{
this.endsWithNewline = true;
}
// This is an optimization. If the current indent is "", then we don't have to do any
// of the more complex stuff further down.
if ((this.currentIndentField.Length == ))
{
this.GenerationEnvironment.Append(textToAppend);
return;
}
// Everywhere there is a newline in the text, add an indent after it
textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField));
// If the text ends with a newline, then we should strip off the indent added at the very end
// because the appropriate indent will be added when the next time Write() is called
if (this.endsWithNewline)
{
this.GenerationEnvironment.Append(textToAppend, , (textToAppend.Length - this.currentIndentField.Length));
}
else
{
this.GenerationEnvironment.Append(textToAppend);
}
}
/// <summary>
/// Write text directly into the generated output
/// </summary>
public void WriteLine(string textToAppend)
{
this.Write(textToAppend);
this.GenerationEnvironment.AppendLine();
this.endsWithNewline = true;
}
/// <summary>
/// Write formatted text directly into the generated output
/// </summary>
public void Write(string format, params object[] args)
{
this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args));
}
/// <summary>
/// Write formatted text directly into the generated output
/// </summary>
public void WriteLine(string format, params object[] args)
{
this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args));
}
/// <summary>
/// Raise an error
/// </summary>
public void Error(string message)
{
System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError();
error.ErrorText = message;
this.Errors.Add(error);
}
/// <summary>
/// Raise a warning
/// </summary>
public void Warning(string message)
{
System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError();
error.ErrorText = message;
error.IsWarning = true;
this.Errors.Add(error);
}
/// <summary>
/// Increase the indent
/// </summary>
public void PushIndent(string indent)
{
if ((indent == null))
{
throw new global::System.ArgumentNullException("indent");
}
this.currentIndentField = (this.currentIndentField + indent);
this.indentLengths.Add(indent.Length);
}
/// <summary>
/// Remove the last indent that was added with PushIndent
/// </summary>
public string PopIndent()
{
string returnValue = "";
if ((this.indentLengths.Count > ))
{
int indentLength = this.indentLengths[(this.indentLengths.Count - )];
this.indentLengths.RemoveAt((this.indentLengths.Count - ));
if ((indentLength > ))
{
returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength));
this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength));
}
}
return returnValue;
}
/// <summary>
/// Remove any indentation
/// </summary>
public void ClearIndent()
{
this.indentLengths.Clear();
this.currentIndentField = "";
}
#endregion
#region ToString Helpers
/// <summary>
/// Utility class to produce culture-oriented representation of an object as a string.
/// </summary>
public class ToStringInstanceHelper
{
private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture;
/// <summary>
/// Gets or sets format provider to be used by ToStringWithCulture method.
/// </summary>
public System.IFormatProvider FormatProvider
{
get
{
return this.formatProviderField ;
}
set
{
if ((value != null))
{
this.formatProviderField = value;
}
}
}
/// <summary>
/// This is called from the compile/run appdomain to convert objects within an expression block to a string
/// </summary>
public string ToStringWithCulture(object objectToConvert)
{
if ((objectToConvert == null))
{
throw new global::System.ArgumentNullException("objectToConvert");
}
System.Type t = objectToConvert.GetType();
System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] {
typeof(System.IFormatProvider)});
if ((method == null))
{
return objectToConvert.ToString();
}
else
{
return ((string)(method.Invoke(objectToConvert, new object[] {
this.formatProviderField })));
}
}
}
private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper();
/// <summary>
/// Helper to produce culture-oriented representation of an object as a string
/// </summary>
public ToStringInstanceHelper ToStringHelper
{
get
{
return this.toStringHelperField;
}
}
#endregion
}
#endregion
}
 MyTextTemplate1.tt
<#@ template language="C#" inherits="SharedFragments" #>
begin
<#SharedText() ;#>
end MyTextTemplate1.cs
// ------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本: 12.0.0.0
//
// 对此文件的更改可能会导致不正确的行为。此外,如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
// ------------------------------------------------------------------------------
namespace Test
{
using System; /// <summary>
/// Class to produce the template output
/// </summary> #line 1 "F:\study\share\Test\MyTextTemplate1.tt"
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "12.0.0.0")]
public partial class MyTextTemplate1 : SharedFragments
{
#line hidden
/// <summary>
/// Create the template output
/// </summary>
public override string TransformText()
{
this.Write("begin 1\r\n "); #line 3 "F:\study\share\Test\MyTextTemplate1.tt"
SharedText() ; #line default
#line hidden
this.Write("end 1\r\n");
return this.GenerationEnvironment.ToString();
}
} #line default
#line hidden
}

使用 T4 文本模板的运行时文本生成

T4运行时模板的更多相关文章

  1. T4学习- 3、创建运行时模板

    使用 Visual Studio 预处理过的文本模板,可以在运行时在应用程序中生成文本字符串. 执行应用程序的计算机不必具有 Visual Studio. 预处理过的模板有时称为"运行时文本 ...

  2. T4设计时模板调试

    在Visual Studio内调试T4设计时模板有多个方法:安装使用带调试功能的第三方工具,利用System.Diagnostics.Debugger实时调试器,VS内置的T4调试工具.使用第三方工具 ...

  3. T4学习- 2、创建设计时模板

    使用设计时 T4 文本模板,您可以在 Visual Studio 项目中生成程序代码和其他文件. 通常,您编写一些模板,以便它们根据来自模型的数据来改变所生成的代码. 模型是包含有关应用程序要求的关键 ...

  4. 魔改——MFC MDI程序 定制 文档模板 运行时全部打开 禁用关闭按钮

    ==================================声明================================== 本文原创,转载在正文中显要的注明作者和出处,并保证文章的完 ...

  5. [c++][语言语法]函数模板和模板函数 及参数类型的运行时判断

    参考:http://blog.csdn.net/beyondhaven/article/details/4204345 参考:http://blog.csdn.net/joeblackzqq/arti ...

  6. 【翻译】利用Qt设计师窗体在运行时创建用户界面(Creating a user interface from a Qt Designer form at run-time)

    利用Qt设计师窗体在运行时创建用户界面 我们利用Calculator窗体例子中创建的窗体(Form)来展示当一个应用(application)已经生成后,是可以在其运行时产生与例子中相同的用户界面. ...

  7. 将asp.net webapi的运行时版本由4.0升级到4.5.1时遇到的问题及解决

    更新package 更改.net运行时的版本之后,出现了错误提示,说需要改新以下组件: EntityFramework, EntityFramework.zh-Hans, Microsoft.AspN ...

  8. MFC六大核心机制之二:运行时类型识别(RTTI)

    上一节讲的是MFC六大核心机制之一:MFC程序的初始化,本节继续讲解MFC六大核心机制之二:运行时类型识别(RTTI). typeid运算子 运行时类型识别(RTTI)即是程序执行过程中知道某个对象属 ...

  9. Runtime运行时机制

    Runtime 又叫运行时,是一套底层的 C 语言 API,其为 iOS 内部的核心之一,我们平时编写的 OC 代码,底层都是基于它来实现的 我们需要了解的是 Objective-C 是一门动态语言, ...

随机推荐

  1. (转).net程序员转战android第一篇---环境部署

    原文,整个序列一样http://www.cnblogs.com/Twmin/p/3148892.html 对于.net开发人员去写java,可谓说是见山是山, 因为太多的相同; 最近段时间因工作因素, ...

  2. Java 装箱、拆箱 包装器

    先说java的基本数据类型.java基本数据类型:byte.short.int.long.float.double.char.boolean 基本数据类型的自动装箱(autoboxing).拆箱(un ...

  3. zeromq源码分析笔记之无锁队列ypipe_t(3)

    在上一篇中说到了mailbox_t的底层实际上使用了管道ypipe_t来存储命令.而ypipe_t实质上是一个无锁队列,其底层使用了yqueue_t队列,ypipe_t是对yueue_t的再包装,所以 ...

  4. Struts2中的get、set方法作用:

    Struts2中的get.set方法作用: 在Struts2中,客户端和服务器之间的数据传输全部要用到get.set方法:用set方法 ,可以将表单中的值存入Action类.通过Struts2.0标签 ...

  5. Android再学习-20140928-布局

    关于布局中的单位 PX是像素,这个没有问题.另外还有两个单位,一个是dp,这个是个相对单位,在任何分辨率的屏幕上显示效果是一样的,所以用dp来进行控件的大小设置.另外,字体的设置推荐用sp,这样字体可 ...

  6. python文件_批量改名

    #! /usr/bin/env python #coding=gbk #文件操作实例--将文件夹下所有图片名称加上'_test' import re,os,time #str.split(path) ...

  7. 环形队列C++实现

    大家好,我是小鸭酱,博客地址为:http://www.cnblogs.com/xiaoyajiang 以下鄙人用C++实现了环形队列 /******************************** ...

  8. memcached在Windows下的安装

    memcached简介详情请谷歌.这里介绍如何在windows下安装. 1.下载     下载地址:http://download.csdn.net/detail/u010562988/9456109 ...

  9. 一键安装IIS的点点滴滴——For所有Microsoft的操作系统(上)

    原文www.cnblogs.com/cdts_change/archive/2010/03/04/1677338.html 临近公司的软件要完工了,最近几天一直在泉哥的带领下为我们公司的产品做IIS一 ...

  10. 可变参数列表-Java SE5新特性(转)

    Java1.5增加了新特性:可变参数:适用于参数个数不确定,类型确定的情况,java把可变参数当做数组处理.注意:可变参数必须位于最后一项.当可变参数个数多于一个时,必将有一个不是最后一项,所以只支持 ...