JSP - 如何从数据库中呈现html(或jsp)代码 [英] JSP - how to render html(or jsp) code from database

查看:112
本文介绍了JSP - 如何从数据库中呈现html(或jsp)代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正在被多个用户组使用的jsp。要求是每个用户组在访问页面时都需要自定义的外观和感觉(具有独特的参数)。我们建议允许用户将他们需要的html转储到数据库表中,并且jsp将确定用户组,并显示相应的html。例如:如果用户组1访问网址abc.com/xyz?param=aaa,那么jsp应该显示html它存储在与UserGroup1相对应的数据库中。同样,abc.com/xyz?param=bbb应该呈现为UserGroup2存储的html。

$ b html第1组:

 < html> hello,用户1< / html> 

html for group 2:

 < html> hello,user 2< / html> 

我的JSP如何从Servlet或任何其他类获取此代码?



任何JSF 2.0建议也是值得欢迎的。上面的例子代码听起来很简单,但实际上整个布局,图像,边界,表,内容将不同

解决方案

而不是保存整个HTML不推荐,因为phanneman说,

保存一个CSS或CSS片段。例如,为每个用户保存数据库,每个用户的图像路径,颜色等等。

这可以通过为每个userGroup重新获取特定数据来帮助。


I have a jsp that is being used by multiple user groups. The requirement is that each User group wants a customized look and feel when they access the page (with a distinguishing parameter). We are proposing to allow the Users to dump the html that they need in a database table and the jsp will determine the User group and they display the corresponding html. Any pointers on how this can be done?

Example: if User group 1 access the url abc.com/xyz?param=aaa, then the jsp should display the html that is stored in the database corresponding to UserGroup1. similarly, abc.com/xyz?param=bbb should render the html stored for UserGroup2.

html for Group 1:

<html>hello, user 1 </html>

html for Group 2:

<html>hello, user 2 </html>

How does my JSP get this html code from Servlets or any other classes?

Any JSF 2.0 suggestions are also welcome.

The above example code might sound simple, but in reality the entire layout, images, borders, tables, content will be different

解决方案

instead of saving entire html which is not recommended as phanneman says,
save a css or css snippets . for example save in your db, the image paths for each user,
color, etc in the db for each user.
this might help by retriving the specific data for each userGroup.

这篇关于JSP - 如何从数据库中呈现html(或jsp)代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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