简体   繁体   English

如何在同一个Web应用程序中生成动态网页

[英]How do generate dynamic web page with in the same web application

I thought of re-framing this question once again, to make it clear. 我想再次重新定义这个问题,以使其清楚。 Thanks a lot the comments. 非常感谢您的评论。 I am developing a web application in which I am making use of widgets. 我正在开发一个Web应用程序,我在其中使用小部件。

Take a real use case scenario, suppose USER-A logins into the my web app and he uses some widgets say A,B and C widgets. 以一个真实的用例场景为例,假设USER-A登录到我的Web应用程序,并且他使用了一些小部件,例如A,B和C小部件。 He places Widget A in the center, WIDGET-B on to the top right hand side and WIDGET-C on to the left hand side of the page. 他将Widget A放在中间,WIDGET-B放在右上角,WIDGET-C放在页面的左侧。

USER_B logins into my system and uses the some widgets and places the widgets in different positions since widgets are made draggable and resizable. USER_B登录到我的系统并使用一些窗口小部件,并将窗口小部件放置在不同的位置,因为窗口小部件可拖动并可以调整大小。 When the user publishes the page the widget should appear exactly in the same position exactly in the same position where he/she placed. 当用户发布页面时,窗口小部件应完全位于他/她所放置的相同位置。

We are using Jquery HTML5 at the front end and servlet and my sql at the back end. 我们在前端使用Jquery HTML5,在后端使用servlet和我的sql。

Wow, you need to take a look at your question and possibly clarify it a bit. 哇,您需要看看您的问题,并可能需要澄清一下。 There are many things in action here, first you talk about personal user spaces, this is very common practice, you need to look into routing requests ( for instance I'd look into rails for zombies tutorial to see how to do this in ROR). 这里有很多事情要做,首先你谈谈个人用户空间,这是很常见的做法,你需要查看路由请求(例如我会看看rails for zombies教程,看看如何在ROR中做到这一点) 。 You also need to define what you are using to develop this: PHP, java, asp etc... your question is lacking a lot of details that make it impossible to answer correctly or usefully. 您还需要定义用于开发此功能的内容:PHP,java,asp等。您的问题缺少很多细节,无法正确或有用地回答。

Finally you need to show us what you have done so far, because its absolutely impossible to see from your question. 最后,您需要向我们展示您到目前为止所做的事情,因为从您的问题中绝对看不到它。 Show us some code, give us more specifications as to what you have done , how and what tools you are using. 向我们展示一些代码,为我们提供更多规范,说明您所做的工作,使用的工具以及使用的工具。

It seems you are starting with this, so you can start by looking at MVC design pattern, and web frameworks that help you implement this. 您似乎从这开始,所以您可以从查看MVC设计模式和帮助您实现此功能的Web框架开始。 Routing is the term used to define how the requests are mapped to your application. 路由是用于定义请求如何映射到应用程序的术语。

Edit: 编辑:

For your widgets its just a matter of storing the positions foe each user and each widget in some efficient way, then loading it upon login, and using your libraries to re-set the positions on the elements. 对于您的窗口小部件,只需以一种有效的方式存储每个用户和每个窗口小部件的位置,然后在登录时加载它,并使用您的库在元素上重新设置位置。 You have to decide where to store it, but most logical approach is server side ( use a DB table or an attribute per widget to store this). 您必须决定在何处存储它,但大多数逻辑方法是服务器端(使用数据库表或每个小部件的属性来存储它)。 Upon login, get the values and return them to the library (either ajax response, or setting js variables etc.. there are many ways). 登录后,获取值并将其返回到库(ajax响应或设置js变量等。有很多方法)。

Forget about users, just consider retrieving any dynamic content. 忘记用户,只考虑检索任何动态内容。 You've got some arbitrary URL 您有一些任意网址

http://mysite.com/some/path/or/other

or possibly with some parameters 或可能带有一些参数

http://mysite.com/some/path/or/other?thing=somevalue

When the browser hits that URL some code of your will run, and you have access to the URL. 当浏览器点击该URL时,您的某些代码将运行,并且您可以访问该URL。 Depending upon the tools you are using you may even have the parts of the URL broken out for you into some useful variables, if not you can extract the bits you care about. 根据您使用的工具,您甚至可以将URL的各个部分分解为一些有用的变量,如果不是,您可以提取您关心的位。

String interestingBit; // somehow gets set to "other"
String thing; // somehow gets set "somevalue"

Now you can write some code to go fetch data from a file or a database, 现在你可以编写一些代码来从文件或数据库中获取数据,

databaseRetrieve( interstingBit, thing);

once again nice frameworks may make all this really easy. 再一次好的框架可能会让这一切变得非常简单。 Then it's just a matter of presenting the data. 然后,这只是提供数据的问题。 So dealing with user-specific content can follow this approach. 因此,处理特定于用户的内容可以遵循这种方法。 You've got to deal with other issues such as deciding how to structure the repository of content and managing the security, but as I understand your question you were asking about the interpretion of the URL. 您必须处理其他问题,例如决定如何构建内容存储库和管理安全性,但正如我理解您的问题,您询问的是URL的解释。

Editedin response to clarified question: 编辑对明确问题的答复:

Seems like you're developing "personalisation" function that is often provided by "Portal" products and frameworks. 您似乎正在开发“个性化”功能,通常由“门户”产品和框架提供。 The key point is that you have a per-user set of preferences, which control what content is displayed and where it is displayed. 关键点在于,您拥有每个用户的首选项集,可以控制显示的内容及其显示位置。 There are many such products, I work for IBM so I know about WebSphere Portal and Lotus Mashups, to name but two. 有很多这样的产品,我为IBM工作,所以我了解WebSphere Portal和Lotus Mashups,仅举两例。

So to implement this you need: 所以要实现这个,你需要:

  1. To base the page composition and layout on data retrieved dynamically, say from a database. 将页面组合和布局基于动态检索的数据,例如从数据库中获取。 For this you need to figure out what to stash in the database (say a list of widget names, their sizes and position, and perhaps their styles and configuration too.) and the how to render a page from that information. 为此,您需要弄清楚要隐藏在数据库中的内容(比如窗口小部件名称列表,它们的大小和位置,也可能是它们的样式和配置。)以及如何从该信息中呈现页面。 I don't know JQuery, but you may have to create a bit of code to do this, not really difficult, but some work. 我不知道JQuery,但你可能需要创建一些代码才能做到这一点,并不是很困难,但有些工作。
  2. How to select a particular instance from the database based on the user's id and the page they select. 如何根据用户的ID和他们选择的页面从数据库中选择特定实例。 Typically the user asks for http://mysite.com/sport and your app knows the user's id from authentication information established earlier in the session and passed around via cookies. 通常,用户要求http://mysite.com/sport ,您的应用程序会从先前在会话中建立的身份验证信息中了解用户的ID,并通过cookie传递。 In the case of Java EE this is just available in the servlet API. 对于Java EE,这只在servlet API中可用。
  3. How to capture the user's edits into something you can save in your repository. 如何将用户的编辑内容捕获到可以保存在存储库中的内容中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM