我正在尋找各種方法來嘗試使請求類型到達我的web服務創建的restfull Webservice到Tomcat,Maven和一些servlet的項目,但沒有我不以一開始錯誤沒有找到資源。我究竟做錯了什麼?我可能沒有配置web.xml?我能怎麼做? 我把文件pom.xml的下方,Restfull Webservice Maven項目netbeans
<dependencies>
<dependency>
<groupId>org.glassfish.metro</groupId>
<artifactId>webservices-rt</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.8.3</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20150729</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
</dependencies>
這是我的web服務的代碼:
@Path("ws")
public class WsUserJson {
@Context
private UriInfo context;
/**
* Creates a new instance of WsUserJson
*/
public WsUserJson() {
}
/**
* Retrieves representation of an instance of com.lillonet.testmavenservletws.WsUserJson
* @return an instance of java.lang.String
*/
@GET
@Produces("application/json")
public String getJson(@QueryParam("name") String nome) {
//TODO return proper representation object
return "{"+nome+"}";
}
/**
* PUT method for updating or creating an instance of WsUserJson
* @param content representation for the resource
* @return an HTTP response with content of the updated or created resource.
*/
@PUT
@Consumes("application/json")
public void putJson(String content) {
}
}