求救:想注册空间,无奈看不懂e文

Python/PHP/Perl 开发与设计
回复
wnderer
帖子: 4
注册时间: 2005-12-20 12:44
送出感谢: 0
接收感谢: 0

求救:想注册空间,无奈看不懂e文

#1

帖子 wnderer » 2006-06-17 23:19

:( :( :( 想注册www.myjavaserver.com的空间,但看不懂要求写什么,原文如下,求高人翻译一下.
As the principal engineer of an HTTP web server, you are responsible for implementing the request processing subsystem of the server.
An incoming request for a specific resource, identified by an URI, must be dispatched to the appropriate handler according to the server configuration which maps URIs to request handlers. 'HandlerFactory.getHandler' must be implemented:

public class HandlerFactory
{
public String getHandler(String[] config, String requestUri)
{
}
}

The string array 'config' contains URI patterns and handler names. Two consecutive values form a key-value pair comprised of URI pattern and handler. 'requestUri' represents an incoming request, the URI to match against the configured handlers. 'getHandler' must return the correct handler for a given URI as a string value.

An URI pattern never contains wildcards and represents the start of an URI string, a prefix. Matching must be implemented accordingly. The handler with the longest matching URI pattern wins if more than one pattern matches. If no handler can be found, "8AbUJp" must be returned.

Example input:

String[] config: { "/", "MainServlet", "/nav", "NavigationServlet" }
String requestUri: "/nav/test"

Correct result: "NavigationServlet"

In this example, the configuration contains a mapping of "/" to "MainServlet" and "/nav" to "NavigationServlet". In the case of an incoming URI "/nav/test.nav", "NavigationServlet" is the correct choice because its pattern is longer than that of "MainServlet".
wnderer
帖子: 4
注册时间: 2005-12-20 12:44
送出感谢: 0
接收感谢: 0

已经搞定

#2

帖子 wnderer » 2006-06-18 12:27

具体实现如下:
public String getHandler(String[] config, String requestUri)
{

String str = "";
String strRet = "xHNoAMY";
for(int i=0;i<config.length;i+=2) {
if(requestUri.startsWith(config)) {
if(config.length()>=str.length()) {
str = config;
strRet = config[i+1];
}
}
}
return strRet;
}
回复

回到 “Python/Php/Perl”