jsp中如何设置代码文本格式

发布于 2024-10-06 09:01:22 字数 171 浏览 0 评论 0原文

您好,我正在创建一个在线测验系统,以便学生可以浏览问题并提交答案。我的问题是有关 C++ 编码的问题,因此它将显示类代码,然后学生可能可以发现语法错误或写出输出。我的问题是如何将问题存储到数据库中,我正在使用 MySQL 我在想它会溢出范围吗?以及在网页中显示时如何格式化代码。有做过在线问答系统经验的人可以给我一些建议吗?谢谢

Hi I am creating a online quiz system, so student can go through the question and submit the answer. My question is something about C++ coding, so it will display a class code, then maybe student can spot the syntax error or write out the output. My question is that how to i store the question into database, I am using MySQL i was thinking will it overflow the range? And how do it format the code during display in webpage. Anyone who had experienced on doing oline quiz system can give me some suggestion? Thank You

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

衣神在巴黎 2024-10-13 09:01:22

如果您担心溢出范围,我建议使用以下 TEXT 类型(在 MySQL 中)而不是 VARCHAR

  • TINYTEXT(最大大小为 256 字节)
  • TEXT(最大大小) 65535 字节或 64KB)
  • MEDIUMTEXT(最大大小为 16777215 字节或 16MB)
  • LONGTEXT(最大大小为 4294967295 字节或 4GB)

您还可以在 TEXT 类型上包含字符集。

至于在网页中显示代码,有syntaxHighlighter。它是一个 javascript 库,您可以将其合并到您的网站中。它们支持多种语言,包括 C++。

希望这有帮助。

If you are worried about overflowing the range, I suggest using the following TEXT types (in MySQL) instead of VARCHAR:

  • TINYTEXT (maximum size of 256 bytes)
  • TEXT (maximum size of 65535 bytes or 64KB)
  • MEDIUMTEXT (maximum size of 16777215 bytes or 16MB)
  • LONGTEXT (maximum size of 4294967295 bytes or 4GB)

You can also include character set on TEXT type too.

As to display code in a web page, there's syntaxHighlighter. It's a javascript library that you can incorporate in your site. They have support for many languages, including C++.

Hope this helps.

浅唱々樱花落 2024-10-13 09:01:22

要将源代码存储在Mysql中,可以使用varchar或TEXT。

要在线编辑源代码,我推荐 markItUp。仅显示(不编辑)可能有更简单的解决方案。

To store sourcecode in Mysql, you can use varchar or TEXT.

To edit source code Online, I recommend markItUp. For displaying only (without edit) there may be simpler solutions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文