我正在尝试编写搜索API的GET请求。我正在编写它public class ApplicationDirectories {
private static final Logger logger =
Logger.getLogger(ApplicationDirectories.class.getName());
private static final Path config;
private static final Path data;
private static final Path cache;
static {
String os = System.getProperty("os.name");
String home = System.getProperty("user.home");
if (os.contains("Mac")) {
config = Paths.get(home, "Library", "Application Support");
data = config;
cache = config;
} else if (os.contains("Windows")) {
String version = System.getProperty("os.version");
if (version.startsWith("5.")) {
config = getFromEnv("APPDATA", false,
Paths.get(home, "Application Data"));
data = config;
cache = Paths.get(home, "Local Settings", "Application Data");
} else {
config = getFromEnv("APPDATA", false,
Paths.get(home, "AppData", "Roaming"));
data = config;
cache = getFromEnv("LOCALAPPDATA", false,
Paths.get(home, "AppData", "Local"));
}
} else {
config = getFromEnv("XDG_CONFIG_HOME", true,
Paths.get(home, ".config"));
data = getFromEnv("XDG_DATA_HOME", true,
Paths.get(home, ".local", "share"));
cache = getFromEnv("XDG_CACHE_HOME", true,
Paths.get(home, ".cache"));
}
}
/** Prevents instantiation. */
private ApplicationDirectories() {
}
/**
* Retrieves a path from an environment variable, substituting a default
* if the value is absent or invalid.
*
* @param envVar name of environment variable to read
* @param mustBeAbsolute whether enviroment variable's value should be
* considered invalid if it's not an absolute path
* @param defaultPath default to use if environment variable is absent
* or invalid
*
* @return environment variable's value as a {@code Path},
* or {@code defaultPath}
*/
private static Path getFromEnv(String envVar,
boolean mustBeAbsolute,
Path defaultPath) {
Path dir;
String envDir = System.getenv(envVar);
if (envDir == null || envDir.isEmpty()) {
dir = defaultPath;
logger.log(Level.CONFIG,
envVar + " not defined in environment"
+ ", falling back on \"{0}\"", dir);
} else {
dir = Paths.get(envDir);
if (mustBeAbsolute && !dir.isAbsolute()) {
dir = defaultPath;
logger.log(Level.CONFIG,
envVar + " is not an absolute path"
+ ", falling back on \"{0}\"", dir);
}
}
return dir;
}
/**
* Returns directory where the native system expects an application
* to store configuration files for the current user. No attempt is made
* to create the directory, and no checks are done to see if it exists.
*
* @param appName name of application
*/
public static Path configDir(String appName)
{
return config.resolve(appName);
}
/**
* Returns directory where the native system expects an application
* to store implicit data files for the current user. No attempt is made
* to create the directory, and no checks are done to see if it exists.
*
* @param appName name of application
*/
public static Path dataDir(String appName)
{
return data.resolve(appName);
}
/**
* Returns directory where the native system expects an application
* to store cached data for the current user. No attempt is made
* to create the directory, and no checks are done to see if it exists.
*
* @param appName name of application
*/
public static Path cacheDir(String appName)
{
return cache.resolve(appName);
}
}
,但我得到的是404.如果我将其写为http://localhost:8280/solr/1.0/search?searchText=abc
,我就能获得JSON响应数据。
我写的是http://localhost:8280/solr/1.0/
并使用网址/*
获取回复。
如果我将其写为http://localhost:8280/solr/1.0/
我没有收到404(/search*
)。
我哪里出错?
答案 0 :(得分:0)
启用wirelogs并检查从AM发送到Backend的请求类型。您可能能够找到原因。请参考http://mytecheye.blogspot.com/2013/09/wso2-esb-all-about-wire-logs.html以启用和分析日志