网页中数据库的换行问题
我用oracle +jsp 在存储数据的时候,有把换行存储进入.但我要显示出来的时候,却不能实现换行,而是一个空格显示出来,哪位高手知道怎么实现换行.先谢过了!
------解决方案--------------------网页上显示的时候换行是 <br> ,而不是\n
------解决方案-------------------- /**
* Function Detail : 对输入的字符处理
* @param pstrWord
* @return
* @throws
java.io.UnsupportedEncodingException */
public static String replaceIn(String pstrWord) throws Exception
{
//pstrWord = replace(pstrWord);
pstrWord = htmlEncode(pstrWord);
pstrWord = pstrWord.replaceAll( "\n ", " <br> ");
pstrWord = pstrWord.replaceAll( " ", "  ");
pstrWord = pstrWord.replaceAll( " ", " ");
return pstrWord;
}
/**
* Function Detail : 对输出的字符处理
* @param pstrWord
* @return
* @throws java.io.Unsupported
EncodingException */
public static String replaceOut(String pstrWord) throws Exception
{
pstrWord = pstrWord.replaceAll( " <br> ", "\n ");
pstrWord = pstrWord.replaceAll( "  ", " ");
pstrWord = pstrWord.replaceAll( " ", " ");
pstrWord = toChinese(pstrWord);
return pstrWord;
}
public static String replace(String pstrWord)
{
if ((pstrWord != null) && (!pstrWord.equals( " ")))
{
pstrWord = pstrWord.replaceAll( " ' ", " ' ' ");
return pstrWord;
}
return " ";
}
调用这两个函数进行转化一下就行了