使用Jsp在浏览器中显示Mysql数据的问题 [英] Problem in Displaying the Mysql data in Browser using Jsp

查看:78
本文介绍了使用Jsp在浏览器中显示Mysql数据的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我创建的表只包含一个varchar类型的字段(8000)。我在该字段中调整了大量数据。


我指定的大小足以让字段占用我的数据。


我正在存储文本文件作为该领域的数据。当我查看表中的内容时,它显示该文本文件中存在的实际内容,如逐行数据。


但是当我使用Jsp重新浏览浏览器中的数据时,它会显示文件中存在的所有内容都没有任何对齐。我希望看到输出,因为我已经看到/存储在数据库中。


可以请建议我正确的方法来解决这个问题..这是mysql或Jsp中的问题吗? div class =h2_lin>解决方案

将文本转换为字符串,然后使用replaceAll方法将所有\ n替换为< BR /> ;.

小心与正则表达式匹配\ n。你需要四个\\来匹配一个\。


感谢您的回复..

其实问题是,


database -table -record将通过linux更新,从那里必须创建一些文本文件并执行shell脚本以将文本文件作为记录存储在单个字段中。之后存储文本文件必须是使用Jsp程序在浏览器中检索。


所以如何将\ n替换为< br \>标签,当我在我的文本文件中没有\ n时。我真的很困惑。


数据库表数据显示


|总计:使用:免费:共享:缓冲:缓存:

内存:515952640 510210048 5742592 0 2199552 118583296

交换:1077469184 572231680 505237504

MemTotal :503860 kB

MemFree:5608 kB

MemShared:0 kB

缓冲区:2148 kB

缓存:62224 kB

SwapCached:53580 kB

有效:382952 kB

ActiveAnon:354608 kB

ActiveCache:28344 kB

Inact_dirty:72288 kB

Inact_laundry:14928 kB

Inact_clean:6720 kB

Inact_target:95376 kB
HighTotal:0 kB

HighFree:0 kB

LowTotal:503860 kB

LowFree:5608 kB

SwapTotal:1052216 kB

SwapFree:493396 kB

HugePages_Total:0

HugePages_Free:0

Hugepagesize :4096 kB |


1排(0.44秒)


附加代码

展开 | 选择 | 换行 | 行号


1。)最好从JSP中删除所有数据库连接代码。 JSP必须只获取结果并显示它们。

2.)您是否尝试将该字符串传递给我建议的replaceAll方法?


Hi ,
i have created table with only one field for the type of varchar(8000) . I am stroed bulk amount of data in that field.

The size i have specified is enough for the field to occupy my data.

I am storing "Text file" as Data to that filed.when i am viewing contents present in the table it shows what actual contents present in that text file like one by one line of data.

But when i am reterving the data in the browser using Jsp, it shows all contents present in the filed is displayed without any alignment. i want see output as i have seen/stored in the database.

could please suggest me the right way to proceed this is problem .. is this the problem in mysql or Jsp?

解决方案

Get the text into a string then use the replaceAll method to replace all \n with <BR />.
Careful with your regex for matching \n. You need four \ to match one \.


thanks for reply..
actually the problem is ,

database -table -record is to be updated through linux, from where some text file has to be created and shell script is executed for storing the text file to database as record in single field.after storing the text file it has to be retrieved in browser using Jsp program.

so how i can replace the \n to <br \> tag when i dont have a \n in my text file. i really confused.

database table data shown

| total: used: free: shared: buffers: cached:
Mem: 515952640 510210048 5742592 0 2199552 118583296
Swap: 1077469184 572231680 505237504
MemTotal: 503860 kB
MemFree: 5608 kB
MemShared: 0 kB
Buffers: 2148 kB
Cached: 62224 kB
SwapCached: 53580 kB
Active: 382952 kB
ActiveAnon: 354608 kB
ActiveCache: 28344 kB
Inact_dirty: 72288 kB
Inact_laundry: 14928 kB
Inact_clean: 6720 kB
Inact_target: 95376 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 503860 kB
LowFree: 5608 kB
SwapTotal: 1052216 kB
SwapFree: 493396 kB
HugePages_Total: 0
HugePages_Free: 0
Hugepagesize: 4096 kB |

1 row in set (0.44 sec)


code attached

Expand|Select|Wrap|Line Numbers


1.) Better remove all that database connection code from the JSP. The JSP must only get the results and display them.
2.) Did you try passing that string to a replaceAll method like I suggested?


这篇关于使用Jsp在浏览器中显示Mysql数据的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆