English 中文(简体)
Jersey WebServer for test an Anders App - got stuck at “hello world”
原标题:Jersey WebServer for testing an Android App - got stuck at "hello world"

我正在开发一个星座,从一个网络服务器那里获得一些数据,我(或者说是其他人)也创造了自己的数据。 现在,为了进行测试,我想设立一个简单的泽西网络服务,我可以通过“http://Get”访问。 我的目标是发出一些检测要求并获得“测试”。 努力。 然而,我以前从未与网络服务器合作,因此,我感到有点丢失。

I followed a German "Hello World" example (it s supposed to show "Yeah" when calling the site localhost:8080/rest/message from the browser).

我的法典如何看待:

import java.io.IOException;
import java.net.InetAddress;

import javax.swing.JOptionPane;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.ext.Provider;

import com.sun.jersey.api.container.httpserver.HttpServerFactory;
import com.sun.net.httpserver.HttpServer;

@Path("test")
@Provider
public class Test
{
    private static InetAddress adress;

    public static void main(String[] args)
    {   
        try
        {
            publishSite();
        }
        catch (IllegalArgumentException e)
        {
            e.printStackTrace();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        System.out.println("Der WebServer wurde unter der Adresse "http://" + adress.getHostAddress() + ":8080/test" veröffentlicht.");
    }

    public static void publishSite() throws IllegalArgumentException, IOException
    {
        adress = InetAddress.getLocalHost();
        HttpServer server = HttpServerFactory.create("http://" + adress.getHostAddress() + ":8080/");
        server.start();

        JOptionPane.showMessageDialog( null, "Ende" );
        server.stop( 0 );
    }


}

(我收到一些错误,说限制入门: 由于对必要的图书馆C:PJavajre6lib t.jar“进行了限制,因此无法进入HttpServer的类型。 错误想法?

并且,根据上述例子:

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

@Path("message")
public class Message {
    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String message() {
        return "Yeah! ";
    }
}

现在,如果我试图进入当地大厅:8080/test/message,我就有一个空页。 当地人:8080/天。 英国广播公司也与任何随机的URL公司一样,我可以认为,与当地东道方:80/blblab一样,这在我看来是一片bit。

我试图从我的安普里特那里获得这种服务,在当地的东道方(80/test/message)上发现了404个错误,当地东道方(80/test)有405个错误。

如果能够帮助的话,我也会把安乐器放在后面,但我已经在谷歌上测试了它,并击退了约html,因此我认为它不是我的问题的起因。

希望你们能够提供帮助,也希望我的问题太迟了。 提前感谢!

P.S.:请在您的心目中,在以上所有地方联系上加上“http://”。 ^

最佳回答

Ok, it WAS apinupid question! ^ 一旦我看望当地人:8080/message,而不是当地人:80/test/message......,它就会被罚款。

然而,如果有人知道我为什么没有在我的浏览器上得到404份答复,我仍然对另一个回答感到高兴!

另外,由于“Access限额”错误,我发现在tgigiel的岗位上很容易找到解决办法

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签