使用Java和jQuery创建PhoneGap应用程序的最佳实践 [英] Best Practice for Creating Phonegap App using Java and jQuery

查看:124
本文介绍了使用Java和jQuery创建PhoneGap应用程序的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我想要创建的是一个Phonegap应用程序使用以下技术。

Basically what I am contemplating creating is a Phonegap App using the following technologies.

HTML -> jQuery -> Java

我想知道的是最好的方法。我知道Phonegap如何工作,并已用于PHP。现在我想弄明白如何使用Java。

What I would like to know is the best way to do this. I am aware of how Phonegap works and have used it with PHP. Now I am trying to figure out how to do it using Java.

使用PHP我将处理所有的服务器端的东西使用jQuery / Ajax与我的PHP脚本交互

With PHP I would handle all of my server side stuff using jQuery / Ajax to interact with my PHP script.

$.ajax({
  url: "serverstuff.php",
  context: document.body
}).done(function() {
  // do something
});

对于Java我假设我需要创建一个Web应用程序并调用.JSP文件,也许类似的东西。

For Java I am assuming I would need to make a web application and call in the .JSP file, maybe something similar.

 $.ajax({
      url: "serverstuff.jsp",
      context: document.body
    }).done(function() {
      // do something
    });

所以我想我要问的是,如果这是一个坏的假设?还是有更好/更实用的方法来做到这一点?此外,如果我使用JSP仅用于服务器端我不需要HTML。所以也许一个Servlet是我正在寻找的。任何指导,建议,过去的经验将是非常有益的。感谢

So I guess what I am asking is if this is a bad assumption? Or is there a better/ more practical way to do this? Also if I use JSP solely for server side I don't need HTML. So maybe a Servlet is what I would be looking for. Any guidance, advice, past experience would be very helpful. Thanks

推荐答案

是的,您可以将任何来自服务器的网址用于处理Ajax请求。
它也可以是一个JSP或任何servlet。

Yes, you can put any url from server for handling Ajax request. It may also be a JSP or any servlet.

它也可以是基于struts框架的something.do文件或任何其他框架扩展,如something.jspx

Also it can be a struts framework based something.do file or any other framework extention like something.jspx etc.

在JSP中,您应该使用scriptlet或自定义标签来编写与PHP类似的HTML代码片段。

In JSP, you should write your html code fragments same like PHP with scriptlets or custom tags.

在Java EE平台上,众所周知的设计模式是模型 - 视图 - 控制器模式。

On the Java EE platform, a well know design pattern is the model-view-controller pattern.

视图是用jsps准备的。
控制器部分,即从哪里控制请求响应流程是servlet。
模型部分是包含DB特定或任何其他存储库/服务特定代码的任何类。

The view is prepared with jsps. The controller part i.e. from where the request response flow is controlled is servlet. The model part is any class which contain DB specific or any other repository/service specific codes.

Jquery总是与jsp / jspx,servlet或任何其他扩展程序,只要它们参与http请求 - 响应模型。

The Jquery always will communicate with jsp/jspx, servlet or any other extension as long as they are participating within a http request-response model.

这篇关于使用Java和jQuery创建PhoneGap应用程序的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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