⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 转换器(converter)——struts 2_0中的魔术师 - max on java - blogjava.htm

📁 struts2标签的详细解释说明教程
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<SPAN style="COLOR: #ff0000">uri</SPAN> <SPAN 
style="COLOR: #0000ff">="/struts-tags"</SPAN> <SPAN 
style="COLOR: #ff0000">%</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN 
style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN 
style="COLOR: #800000">html</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> 
<SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN> 
<SPAN style="COLOR: #800000">head</SPAN> <SPAN 
style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp; 
&nbsp; </SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN 
style="COLOR: #800000">title</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> 
<SPAN style="COLOR: #000000">Hello World</SPAN> <SPAN 
style="COLOR: #0000ff">&lt;/</SPAN> <SPAN style="COLOR: #800000">title</SPAN> 
<SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN 
style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN> 
<SPAN style="COLOR: #800000">head</SPAN> <SPAN 
style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR></SPAN><SPAN 
style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">body</SPAN> 
<SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp; 
&nbsp; </SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN 
style="COLOR: #800000">s:form </SPAN><SPAN style="COLOR: #ff0000">action</SPAN> 
<SPAN style="COLOR: #0000ff">="HelloWorld"</SPAN> <SPAN 
style="COLOR: #ff0000">theme</SPAN> <SPAN 
style="COLOR: #0000ff">="simple"</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> 
<SPAN style="COLOR: #000000">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<BR>&nbsp; 
&nbsp; &nbsp; &nbsp; Locale: </SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN> 
<SPAN style="COLOR: #800000">s:textfield </SPAN><SPAN 
style="COLOR: #ff0000">name</SPAN> <SPAN style="COLOR: #0000ff">="loc"</SPAN> 
<SPAN style="COLOR: #ff0000"></SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN> 
<SPAN style="COLOR: #ff0000">&amp;nbsp;</SPAN> <SPAN 
style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">s:submit 
</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN> <SPAN 
style="COLOR: #000000"><BR>&nbsp; &nbsp; </SPAN><SPAN 
style="COLOR: #0000ff">&lt;/</SPAN> <SPAN style="COLOR: #800000">s:form</SPAN> 
<SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000">&nbsp; 
&nbsp;<BR>&nbsp; &nbsp; </SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN 
style="COLOR: #800000">h2</SPAN> <SPAN style="COLOR: #0000ff">&gt;&lt;</SPAN> 
<SPAN style="COLOR: #800000">s:property </SPAN><SPAN 
style="COLOR: #ff0000">value</SPAN> <SPAN style="COLOR: #0000ff">="msg"</SPAN> 
<SPAN style="COLOR: #ff0000"></SPAN><SPAN 
style="COLOR: #0000ff">/&gt;&lt;/</SPAN> <SPAN style="COLOR: #800000">h2</SPAN> 
<SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN 
style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN> 
<SPAN style="COLOR: #800000">body</SPAN> <SPAN 
style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR></SPAN><SPAN 
style="COLOR: #0000ff">&lt;/</SPAN> <SPAN style="COLOR: #800000">html</SPAN> 
<SPAN style="COLOR: #0000ff">&gt;</SPAN> </DIV>
<P>接下来,在源代码文件夹的tutorial包中新建LocaleConverter.java文件,代码如下:<BR></P>
<DIV 
style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/None.gif" 
align=top> <SPAN style="COLOR: #0000ff">package</SPAN> <SPAN 
style="COLOR: #000000">tutorial;<BR><IMG 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/None.gif" 
align=top><BR><IMG 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/None.gif" 
align=top></SPAN> <SPAN style="COLOR: #0000ff">import</SPAN> <SPAN 
style="COLOR: #000000">java.util.Locale;<BR><IMG 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/None.gif" 
align=top></SPAN> <SPAN style="COLOR: #0000ff">import</SPAN> <SPAN 
style="COLOR: #000000">java.util.Map;<BR><IMG 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/None.gif" 
align=top><BR><IMG id=Codehighlighter1_130_478_Open_Image 
onclick="this.style.display='none'; Codehighlighter1_130_478_Open_Text.style.display='none'; Codehighlighter1_130_478_Closed_Image.style.display='inline'; Codehighlighter1_130_478_Closed_Text.style.display='inline';" 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/ExpandedBlockStart.gif" 
align=top><IMG id=Codehighlighter1_130_478_Closed_Image style="DISPLAY: none" 
onclick="this.style.display='none'; Codehighlighter1_130_478_Closed_Text.style.display='none'; Codehighlighter1_130_478_Open_Image.style.display='inline'; Codehighlighter1_130_478_Open_Text.style.display='inline';" 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/ContractedBlock.gif" 
align=top></SPAN> <SPAN style="COLOR: #0000ff">public</SPAN> <SPAN 
style="COLOR: #000000"></SPAN><SPAN style="COLOR: #0000ff">class</SPAN> <SPAN 
style="COLOR: #000000">LocaleConverter </SPAN><SPAN 
style="COLOR: #0000ff">extends</SPAN> <SPAN 
style="COLOR: #000000">ognl.DefaultTypeConverter </SPAN><SPAN 
id=Codehighlighter1_130_478_Closed_Text 
style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/dot.gif"> 
</SPAN><SPAN id=Codehighlighter1_130_478_Open_Text><SPAN 
style="COLOR: #000000">{<BR><IMG 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/InBlock.gif" 
align=top> &nbsp; &nbsp;@Override<BR><IMG id=Codehighlighter1_212_476_Open_Image 
onclick="this.style.display='none'; Codehighlighter1_212_476_Open_Text.style.display='none'; Codehighlighter1_212_476_Closed_Image.style.display='inline'; Codehighlighter1_212_476_Closed_Text.style.display='inline';" 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/ExpandedSubBlockStart.gif" 
align=top><IMG id=Codehighlighter1_212_476_Closed_Image style="DISPLAY: none" 
onclick="this.style.display='none'; Codehighlighter1_212_476_Closed_Text.style.display='none'; Codehighlighter1_212_476_Open_Image.style.display='inline'; Codehighlighter1_212_476_Open_Text.style.display='inline';" 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/ContractedSubBlock.gif" 
align=top> &nbsp; &nbsp;</SPAN> <SPAN style="COLOR: #0000ff">public</SPAN> <SPAN 
style="COLOR: #000000">Object convertValue(Map context, Object value, Class 
toType) </SPAN><SPAN id=Codehighlighter1_212_476_Closed_Text 
style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/dot.gif"> 
</SPAN><SPAN id=Codehighlighter1_212_476_Open_Text><SPAN 
style="COLOR: #000000">{<BR><IMG id=Codehighlighter1_243_356_Open_Image 
onclick="this.style.display='none'; Codehighlighter1_243_356_Open_Text.style.display='none'; Codehighlighter1_243_356_Closed_Image.style.display='inline'; Codehighlighter1_243_356_Closed_Text.style.display='inline';" 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/ExpandedSubBlockStart.gif" 
align=top><IMG id=Codehighlighter1_243_356_Closed_Image style="DISPLAY: none" 
onclick="this.style.display='none'; Codehighlighter1_243_356_Closed_Text.style.display='none'; Codehighlighter1_243_356_Open_Image.style.display='inline'; Codehighlighter1_243_356_Open_Text.style.display='inline';" 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/ContractedSubBlock.gif" 
align=top> &nbsp; &nbsp; &nbsp; &nbsp;</SPAN> <SPAN 
style="COLOR: #0000ff">if</SPAN> <SPAN style="COLOR: #000000">(toType 
</SPAN><SPAN style="COLOR: #000000">==</SPAN> <SPAN 
style="COLOR: #000000">Locale.</SPAN> <SPAN style="COLOR: #0000ff">class</SPAN> 
<SPAN style="COLOR: #000000">) </SPAN><SPAN 
id=Codehighlighter1_243_356_Closed_Text 
style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/dot.gif"> 
</SPAN><SPAN id=Codehighlighter1_243_356_Open_Text><SPAN 
style="COLOR: #000000">{<BR><IMG 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/InBlock.gif" 
align=top> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;String locale </SPAN><SPAN 
style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">((String[]) 
value)[</SPAN> <SPAN style="COLOR: #000000">0</SPAN> <SPAN 
style="COLOR: #000000">];<BR><IMG 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/InBlock.gif" 
align=top> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</SPAN> <SPAN 
style="COLOR: #0000ff">return</SPAN> <SPAN style="COLOR: #000000"></SPAN><SPAN 
style="COLOR: #0000ff">new</SPAN> <SPAN 
style="COLOR: #000000">Locale(locale.substring(</SPAN> <SPAN 
style="COLOR: #000000">0</SPAN> <SPAN style="COLOR: #000000">, </SPAN><SPAN 
style="COLOR: #000000">2</SPAN> <SPAN style="COLOR: #000000">), 
locale.substring(</SPAN> <SPAN style="COLOR: #000000">3</SPAN> <SPAN 
style="COLOR: #000000">));<BR><IMG id=Codehighlighter1_390_458_Open_Image 
onclick="this.style.display='none'; Codehighlighter1_390_458_Open_Text.style.display='none'; Codehighlighter1_390_458_Closed_Image.style.display='inline'; Codehighlighter1_390_458_Closed_Text.style.display='inline';" 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/ExpandedSubBlockStart.gif" 
align=top><IMG id=Codehighlighter1_390_458_Closed_Image style="DISPLAY: none" 
onclick="this.style.display='none'; Codehighlighter1_390_458_Closed_Text.style.display='none'; Codehighlighter1_390_458_Open_Image.style.display='inline'; Codehighlighter1_390_458_Open_Text.style.display='inline';" 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/ContractedSubBlock.gif" 
align=top> &nbsp; &nbsp; &nbsp; &nbsp;}</SPAN> </SPAN><SPAN 
style="COLOR: #000000"></SPAN><SPAN style="COLOR: #0000ff">else</SPAN> <SPAN 
style="COLOR: #000000"></SPAN><SPAN style="COLOR: #0000ff">if</SPAN> <SPAN 
style="COLOR: #000000">(toType </SPAN><SPAN style="COLOR: #000000">==</SPAN> 
<SPAN style="COLOR: #000000">String.</SPAN> <SPAN 
style="COLOR: #0000ff">class</SPAN> <SPAN style="COLOR: #000000">) </SPAN><SPAN 
id=Codehighlighter1_390_458_Closed_Text 
style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/dot.gif"> 
</SPAN><SPAN id=Codehighlighter1_390_458_Open_Text><SPAN 
style="COLOR: #000000">{<BR><IMG 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/InBlock.gif" 
align=top> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Locale locale </SPAN><SPAN 
style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">(Locale) 
value;<BR><IMG 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/InBlock.gif" 
align=top> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</SPAN> <SPAN 
style="COLOR: #0000ff">return</SPAN> <SPAN 
style="COLOR: #000000">locale.toString();<BR><IMG 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/ExpandedSubBlockEnd.gif" 
align=top> &nbsp; &nbsp; &nbsp; &nbsp;}</SPAN> </SPAN><SPAN 
style="COLOR: #000000"><BR><IMG 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/InBlock.gif" 
align=top> &nbsp; &nbsp; &nbsp; &nbsp;</SPAN> <SPAN 
style="COLOR: #0000ff">return</SPAN> <SPAN style="COLOR: #000000"></SPAN><SPAN 
style="COLOR: #0000ff">null</SPAN> <SPAN style="COLOR: #000000">;<BR><IMG 
src="转换器(Converter)——Struts 2_0中的魔术师 - Max On Java - BlogJava.files/ExpandedSubBlockEnd.gif" 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -