Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it L'avatar di Ironmax
    Registrato dal
    Dec 2008
    Messaggi
    1,025

    Problemi con Rest, non riesco a trovare la servlet

    Salve.
    Ho approdato alla tecnologia Rest.
    Riesco a far avviare la pagina di index.jsp del progetto ma ho un errore di all'indirizzo
    http://localhost:8080/SimpleRestWeb/rest/hello/Max:
    HTTP Status 404 -


    type Status report
    message
    description The requested resource is not available.

    Apache Tomcat/7.0.55

    Questo è il file xml:
    codice:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
      <display-name>SimpleRestWeb</display-name>
      <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
      </welcome-file-list>
      
      <display-name>Restful Web Application</display-name>
    
        <servlet>
            <servlet-name>helloworld</servlet-name>
            <servlet-class>
                         com.sun.jersey.spi.container.servlet.ServletContainer
                    </servlet-class>
            <init-param>
                 <param-name>com.sun.jersey.config.property.packages</param-name>
                 <param-value>com.rest.example</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
    
        <servlet-mapping>
            <servlet-name>helloworld</servlet-name>
            <url-pattern>/rest/*</url-pattern>
        </servlet-mapping>
    </web-app>
    sotto c'è il file della servlet:
    codice:
    package com.rest.example;
    
    import javax.ws.rs.GET;
    import javax.ws.rs.Path;
    import javax.ws.rs.PathParam;
    import javax.ws.rs.core.Response;
    
    
    @Path("/hello")
    public class HelloWorld {
    
        @GET
        @Path("/{param}")
        public javax.ws.rs.core.Response getMsg(@PathParam("param") String msg) {
        String output = "Ben venuto nel mondo Rest: " + msg;
        return Response.status(200).entity(output).build();
        
        }
    }
    Qualcuno ha qualche idea? Grazie

  2. #2
    Utente di HTML.it L'avatar di andbin
    Registrato dal
    Jan 2006
    residenza
    Italy
    Messaggi
    18,254
    Quote Originariamente inviata da Ironmax Visualizza il messaggio
    Qualcuno ha qualche idea?
    Dipendenze jar usate? Eccezioni? Errori di deploy? Log di Tomcat?
    Andrea, andbin.devSenior Java developerSCJP 5 (91%) • SCWCD 5 (94%)
    Java Versions Cheat Sheet

  3. #3
    Utente di HTML.it L'avatar di Ironmax
    Registrato dal
    Dec 2008
    Messaggi
    1,025
    Quote Originariamente inviata da andbin Visualizza il messaggio
    Dipendenze jar usate? Eccezioni? Errori di deploy? Log di Tomcat?
    Mi sono accorto di non avere inserito le librerie:
    asm-3.1.jar
    jersey-core-1.8.jar
    jersey-server-1.8.jar
    All'interno della cartella WebContent\WEB-INF\lib
    Adesso funziona
    Ultima modifica di Ironmax; 07-12-2016 a 00:04

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.