简体   繁体   English

如何创建允许您导航到不同页面的桌面应用程序?

[英]How to create a desktop application which allows you to navigate to different pages?

I have experience in PHP web development. 我有PHP Web开发方面的经验。 I am trying to learn to create a desktop application in Java. 我正在尝试学习用Java创建桌面应用程序。 My first roadblock is, how do I create a desktop application which allows you to navigate to different pages like as possible in a web application? 我的第一个障碍是,如何创建桌面应用程序,使您可以像浏览Web应用程序一样导航至不同页面?

If you mean desktop and not Web applications, then you should look at appropriate desktop application frameworks. 如果您指的是台式机而不是Web应用程序,则应查看适当的桌面应用程序框架。 These are different from JSP or Play!. 这些不同于JSP或Play!。

  • Swing is the classic one, but kind of old (and Oracle is no more investing in it) Swing是经典的,但有点陈旧(Oracle不再对其进行投资)
  • SWT comes from the Eclipse community. SWT来自Eclipse社区。 Powerful, open source, etc. 强大的开源等
  • Java FX is seen by some as the modern successor of Swing. Java FX被某些人视为Swing的现代继任者。 Oracle actively promotes it in conferences, etc. Oracle在会议等方面积极推广它。
  • Griffon - easy to use and a very good choice if you don't mind dealing a programming language different than Java (Groovy in this case). Griffon-易于使用,如果您不介意使用不同于Java的编程语言(在这种情况下为Groovy),则是一个很好的选择。 It also offers support for Java. 它还提供对Java的支持。

i think you are looking for JSP, you need to use a application (web container) server which can run your JSP. 我认为您正在寻找JSP,您需要使用可以运行JSP的应用程序(Web容器)服务器。

look at Apache Tomcat , one of the most widely used web containers for Java. 看一下Apache Tomcat ,它是Java中使用最广泛的Web容器之一。 here are some samples 这是一些样品

Hope this helps.. 希望这可以帮助..

You have a few options. 您有几种选择。

The main option you'll hear about is Java EE , which includes JSPs, servlets, and such. 您将听到的主要选项是Java EE ,其中包括JSP,Servlet等。 These run in a "container" that provides the framework. 它们在提供框架的“容器”中运行。 Tomcat is a very popular open-source container which provides for JSPs and servlets (it's not a full-on Java EE container, but it doesn't sound like you need one). Tomcat是一个非常流行的开源容器,它提供JSP和servlet(它不是完整的Java EE容器,但听起来好像不需要一个容器)。

The Play! 戏! framework is another increasingly popular option. 框架是另一个越来越流行的选择。 It breaks from the Java EE mold and shoots for rapid development cycles and such. 它打破了Java EE的模式,并为快速的开发周期等而努力。

Another option is to use Mongrel2 with a Java connector. 另一个选择是将Mongrel2与Java连接器一起使用。

To achieve what you want in Java you should make a Web Application . 要实现Java所需的功能,您应该制作一个Web应用程序 Considering that you are coming from PHP developement experience, I suggest you to start with JSP technology, which is quite similar to php (for similar I mean that you have your HTML page and you can embed java code by using special tags). 考虑到您来自PHP开发经验,因此建议您从JSP技术入手,该技术与php十分相似(类似的意思是您拥有HTML页面,并且可以使用特殊标签嵌入Java代码)。 This is a tutorial that could be useful to you in order to start building a web application. 教程对您开始构建Web应用程序可能很有用。

If you are using eclipse as your IDE, you could start by creating a new Dynamic Web Project , letting eclipse build most of the bolierplate code for you (you can do this with other IDEs though). 如果您将eclipse用作IDE,则可以从创建一个新的Dynamic Web Project开始 ,让eclipse为您构建大部分的bolierplate代码(不过您可以使用其他IDE来完成)。

This is a simple JSP page that you can use as a start: 这是一个简单的JSP页面,您可以将其用作开始:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Insert title here</title>
</head>
<body>
  <p>Html code</p>
  <p><% out.print("Java code"); %></p>
</body>
</html>

Once you will be familiar with JSP technology, you will notice that JSP have some limitations especially if you want to build complex web applications (one of them is that embedding java code into a web page could be confusing and hard to debug, and it's considered a bad practice nowadays). 熟悉JSP技术后,您会注意到JSP有一些局限性,尤其是当您要构建复杂的Web应用程序时(其中之一是将Java代码嵌入到网页中可能会造成混淆并且难以调试,因此可以考虑将其考虑在内)时下的不良习惯)。 But, having that knowledge, you could easily move to some more complex and proficient technologies, suck as JSF . 但是,有了这些知识,您就可以轻松地迁移到一些更复杂和精通的技术,就像JSF一样

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

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