Jersey Web Applicationorg.glassfish.jersey.servlet.ServletContainerjersey.config.server.provider.packagescom.company.test.jerseyprojectjersey.config.server.provider.classnamesorg.glassfish.jersey.server.mvc.jsp.JspMvcFeaturejersey.config.server.mvc.templateBasePath.jsp/WEB-INF/jsp1Jersey Web Application/webapi/*
package com.company.test.jerseyproject;
import java.util.HashMap;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.server.mvc.Viewable;
/**
* Root resource (exposed at "myresource" path)
*/
@Path("myresource")
public class MyResource {
/**
* Method handling HTTP GET requests. The returned object will be sent
* to the client as "text/plain" media type.
*
* @return String that will be returned as a text/plain response.
*/
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getIt() {
return "Got it!";
}
@GET
@Path("/hello")
public Viewable sayHello(@QueryParam("name") @DefaultValue("World") String name) {
HashMap model = new HashMap();
model.put("name", name);
return new Viewable("/hello", model);
}
@GET
@Path("/hello1/{param}")
public Response sayHelloToResponse(@PathParam("param") String msg) {
String output = "Jersey say : " + msg;
return Response.status(200).entity(output).build();
}
@GET
@Path("/hello2/{param}")
@Produces("text/plain;charset=UTF-8")
public String sayHelloToUTF8(@PathParam("param") String username) {
return "Hello " + username;
}
}
6. Build and Deploy
http://localhost:8080/jerseyproject/webapi/myresource/hello Hello, World http://localhost:8080/jerseyproject/webapi/myresource/hello?name=aaaa Hello, aaaa http://localhost:8080/jerseyproject/webapi/myresource/hello1/bbb Jersey say : bbb http://localhost:8080/jerseyproject/webapi/myresource/hello2/cccc Hello cccc
用原型函数(prototype)可以定义一些很方便的自定义函数,实现各种自定义功能。本次主要是实现了Array的去重、获取最大值和最小值。
实现代码如下:
<script type="text/javascript">
Array.prototype.unique = function() {
var a = {};
var le
ORACLE
下面这个效率很低
SELECT * FROM ( SELECT A.*, ROWNUM RN FROM (SELECT * FROM IPAY_RCD_FS_RETURN order by id desc) A ) WHERE RN <20;
下面这个效率很高
SELECT A.*, ROWNUM RN FROM (SELECT * FROM IPAY_RCD_
Reverse a singly linked list.
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
p