Java代码 :
oyhk 学习笔记
下面是java把html标签字符转换,我用了spring 包中的 org.springframework.web.util.HtmlUtils
了解了源代码并且进步了使用,发现写得真不错...同时也可以,看看别人的工具是怎么写的,增长知识了
TestHtmlUtils
package test.org.springframework.web.util; import org.junit.Test; import org.springframework.web.util.HtmlUtils; /** * 测试htmlUtils 功能 * @author hk * * 2012-12-27 下午11:22:53 */ public class TestHtmlUtils { String html = "<ul ><li><a href="http://www.mkfree.com">首 页</a></li>"+ "<li ><a href="http://blog.mkfree.com">博客</a></li>"+ "<li><a href="#">RSS</a></li></ul>"; /** * 把html的标签特殊字符转换成普通字符 */ @Test public void testhtmlEscape(){ String value = HtmlUtils.htmlEscape(html); System.out.println(value); } /** * 把html的特殊字符转换成普通数字 */ @Test public void testhtmlEscapeDecimal(){ String value = HtmlUtils.htmlEscapeDecimal(html); System.out.println(value); } /** * 把html的特殊字符转换成符合Intel HEX文件的字符串 */ @Test public void htmlEscapeHex(){ String value = HtmlUtils.htmlEscapeHex(html); System.out.println(value); } /** * 把html的特殊字符反转换成html标签 * 以上三种方法都可以反转换 */ @Test public void htmlUnescape(){ String tmp = HtmlUtils.htmlEscapeDecimal(html); System.out.println(tmp); String value = HtmlUtils.htmlUnescape(tmp); System.out.println(value); } }
本文章来自:http://blog.mkfree.com/posts/19
已有 0 人发表留言,猛击->>这里<<-参与讨论
ITeye推荐
- —软件人才免语言低担保 赴美带薪读研!—
VS自动编译代码脚本
把以下代码保存为.bat,即可使用。
作者楼主师傅midas---范
@echo "5秒钟后默认开始后台编译:"
@ping 127.0.0.1 -n 5 1>nul 2>nul
set svn_home=D:\Program Files\bin
set svn_work=D:\bridge\SVN_Bridge\trunk
set svn_solution=D:\bridge\SVN_Bridge\build
set OutputDir=C:\Users\liuym\Desktop
DEL C:\Users\liuym\Desktop\releaseOutput.txt
DEL C:\Users\liuym\Desktop\debugOutput.txt
set VSInstall_route=D:\Program Files\Common7\IDE
set System_route=C:\WINDOWS
set ProgramFile=C:\Program Files
set Solution="D:\bridge\SVN_Bridge\build\All_for Debug.sln"
"%svn_home%"\TortoiseProc.exe/command:update /path:"%svn_work%*%svn_solution%" /quiet /notempfile /closeonend:1
path=%VSInstall_route%\Common7\IDE;%System_route%\System32;%System_route% ;%System_route%\System32\wbem;%VSInstall_route%\Common7\bin;%VSInstall_route%\Common7\PlatformSDK\bin;%VSInstall_route%Common7\Tools\bin;%VSInstall_route%\Common7\tools;%ProgramFile%\HTML Help Workshop;%VSInstall_route%;%VSInstall_route%\SDK\v2.0\bin;%System_route%\SysWow64;
@echo Build DeBug Start!!!
time /T >> C:\Users\liuym\Desktop\releaseOutput.txt
devenv %Solution% /build "Debug|Win32" /Out %OutputDir%\debugOutput.txt
devenv %Solution% /build "Debug|Win32" /Out %OutputDir%\debugOutput.txt
devenv %Solution% /build "Debug|Win32" /Out %OutputDir%\debugOutput.txt
@echo Debug Build Finish!!!
time /T >> C:\Users\liuym\Desktop\releaseOutput.txt
@echo Build Release Start!!!
time /T >> C:\Users\liuym\Desktop\releaseOutput.txt
devenv %Solution% /build "Release|Win32" /Out %OutputDir%\releaseOutput.txt
devenv %Solution% /build "Release|Win32" /Out %OutputDir%\releaseOutput.txt
devenv %Solution% /build "Release|Win32" /Out %OutputDir%\releaseOutput.txt
@echo Release Build Finish!!!
time /T >> C:\Users\liuym\Desktop\releaseOutput.txt
%System_route%\system32\Shutdown.exe -s -f -t 30