html5显示helloworld,helloworld-html5

The

helloworld-html5 quickstart demonstrates the use of CDI 1.2 and JAX-RS 2.0 using the HTML5 architecture and RESTful services on the backend.

What is it?

The helloworld-html5 quickstart demonstrates the use of CDI 1.2 and JAX-RS 2.0 in JBoss Enterprise Application Platform Server 7.2 or later using the HTML5 + REST architecture.

The application is basically a smart, HTML5, CSS3, and JavaScript front-end using RESTful services on the backend.

HelloWorld.java: Establishes the RESTful endpoints using JAX-RS.

web.xml: Maps RESTful endpoints to /hello.

index.html: Is a jQuery augmented plain old HTML5 web page.

The example can be deployed using Maven from the command line or from Eclipse using JBoss Tools.

System Requirements

The application this project produces is designed to be run on JBoss Enterprise Application Platform Server 7.2 or later.

All you need to build this project is Java 8.0 (Java SDK 1.8) or later and Maven 3.3.1 or later. See Configure Maven to Build and Deploy the Quickstarts to make sure you are configured correctly for testing the quickstarts.

An HTML5 compatible browser such as Chrome, Safari 5+, Firefox 5+, or IE 9+ is required.

With the prerequisites out of the way, you are ready to build and deploy.

Use of EAP_HOME

In the following instructions, replace EAP_HOME with the actual path to your JBoss EAP installation. The installation path is described in detail here: Use of EAP_HOME and JBOSS_HOME Variables.

Start the JBoss EAP Standalone Server

Open a terminal and navigate to the root of the JBoss EAP directory.

Start the JBoss EAP server with the default profile by typing the following command.

$ EAP_HOME/bin/standalone.sh

Note

For Windows, use the EAP_HOME\bin\standalone.bat script.

Build and Deploy the Quickstart

Make sure you start the JBoss EAP server as described above.

Open a terminal and navigate to the root directory of this quickstart.

Type the following command to build the artifacts.

$ mvn clean package wildfly:deploy

This deploys the helloworld-html5/target/helloworld-html5.war to the running instance of the server.

You should see a message in the server log indicating that the archive deployed successfully.

Access the Application

The application will be running at the following URL http://localhost:8080/helloworld-html5/.

You can also test the REST endpoint by sending an HTTP POST request to the URLs below. Replace YOUR_NAME with a name of your choosing.

Test the XML Content

You can test The XML content by sending an HTTP POST to the following URL: http://localhost:8080/helloworld-html5/hello/xml/YOUR_NAME

Type the following cURL command in terminal to issue the POST command:

curl -i -X POST http://localhost:8080/${project.artifactId}/hello/xml/__YOUR_NAME__

You will see the following response:

Connection: keep-alive

HTTP/1.1 200 OK

X-Powered-By: Undertow/1

Server: JBoss-EAP/7

Content-Type: application/xml

Content-Length: 44

Date: Tue, 13 Oct 2015 18:40:04 GMT

Hello YOUR_NAME!

Test the JSON Content

You can test the JSON content by sending an HTTP POST to the following URL: http://localhost:8080/helloworld-html5/hello/json/YOUR_NAME

Type the following cURL command in terminal to issue the POST command:

curl -i -X POST http://localhost:8080/${project.artifactId}/hello/json/YOUR_NAME

You will see the following response:

HTTP/1.1 200 OK

Connection: keep-alive

X-Powered-By: Undertow/1

Server: JBoss-EAP/7

Content-Type: application/json

Content-Length: 29

Date: Tue, 13 Oct 2015 06:32:20 GMT

{"result":"Hello YOUR_NAME!"}

Undeploy the Quickstart

When you are finished testing the quickstart, follow these steps to undeploy the archive.

Make sure you start the JBoss EAP server as described above.

Open a terminal and navigate to the root directory of this quickstart.

Type this command to undeploy the archive:

$ mvn wildfly:undeploy

Run the Arquillian Functional Tests

This quickstart provides Arquillian functional tests. They are located under the functional-tests/ directory. Functional tests verify that your application behaves correctly from the user’s point of view and simulate clicking around the web page as a normal user would do.

Note

The Arquillian functional tests deploy the application, so make sure you undeploy the quickstart before you begin.

Follow these steps to run the functional tests.

Build the quickstart archive.

Open a terminal and navigate to the root directory of this quickstart.

Build the quickstart archive using the following command:

$ mvn clean package

Navigate to the functional-tests/ directory in this quickstart.

Type the following command to run the verify goal with the arq-remote profile activated.

$ mvn clean verify -Parq-remote

Note

You can also let Arquillian manage the JBoss EAP server by using the arq-managed profile, meaning the tests will start the server for you. This profile requires that you provide Arquillian with the location of the JBoss EAP server, either by setting the JBOSS_HOME environment variable, or by setting the jbossHome property in the arquillian.xml file. For more information, see Run the Arquillian Tests.

Run the Quickstart in Red Hat JBoss Developer Studio or Eclipse

You can also start the server and deploy the quickstarts or run the Arquillian tests in Red Hat JBoss Developer Studio or from Eclipse using JBoss tools. For general information about how to import a quickstart, add a JBoss EAP server, and build and deploy a quickstart, see Use JBoss Developer Studio or Eclipse to Run the Quickstarts.

Debug the Application

If you want to debug the source code or look at the Javadocs of any library in the project, run either of the following commands to pull them into your local repository. The IDE should then detect them.

$ mvn dependency:sources

$ mvn dependency:resolve -Dclassifier=javadoc

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值