[此贴子已经被作者于2006-12-18 13:40:26编辑过]
各位还是没太明白我的意思,如下:<%@ page contentType="text/html; charset=gb2312" %><%@ page import="test.Mytest"%><html> <head> <title>123 </title> </head> <body>
<% String str="<h1><b>123</b></h1>"; String sstr=Mytest.toHtmlString(str); out.println(sstr); %> </body></html>然后在Mytest类中写个toHtmlString的方法实现转化,这种方法是可行的现在想问有没有更简单一点儿办法,如果用转义的话,上面的代码也能打出来,不过如果要打的代码很长还能一个一个的去转吗?
str.Replace(">",">")str.Replace("<",">")str.Replace(" "," ")str.Replace("\n","<br>")等等
Thanks for rainic,that's what I want!But there's mistake in your code:str.replace()Thanks!