本文整理了Java中spark.Spark.staticFileLocation()
方法的一些代码示例,展示了Spark.staticFileLocation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Spark.staticFileLocation()
方法的具体详情如下:
包路径:spark.Spark
类名称:Spark
方法名:staticFileLocation
[英]Sets the folder in classpath serving static files. Observe: this method must be called before all other methods.
[中]设置类路径中服务静态文件的文件夹。注意:必须在调用所有其他方法之前调用此方法。
代码示例来源:origin: bwssytems/ha-bridge
staticFileLocation("/public");
initExceptionHandler((e) -> HABridge.theExceptionHandler(e, bridgeSettings.getBridgeSettingsDescriptor().getServerPort()));
if(!bridgeSettings.getBridgeControl().isReinit())
代码示例来源:origin: eh3rrera/minitwit
public WebConfig(MiniTwitService service) {
this.service = service;
staticFileLocation("/public");
setupRoutes();
}
代码示例来源:origin: cinchapi/concourse
/**
* Start the server.
*/
public void start() {
if(running.compareAndSet(false, true)) {
Spark.setPort(port);
Spark.staticFileLocation(staticFileLocation);
// Register all the EndpointContainers and listen for any requests
Reflections reflections = new Reflections(
"com.cinchapi.concourse.server.http.router");
Set<EndpointContainer> weighted = Sets.newTreeSet();
for (Class<? extends EndpointContainer> container : reflections
.getSubTypesOf(EndpointContainer.class)) {
EndpointContainer instance = Reflection.newInstance(container,
concourse);
weighted.add(instance);
}
for (EndpointContainer instance : weighted) {
initialize(instance);
}
Logger.info("HTTP Server enabled on port {}", port);
}
}
代码示例来源:origin: GoogleCloudPlatform/java-docs-samples
/**
* Creates a controller that maps requests to actions.
*/
public UserController(final UserService userService) {
Spark.staticFileLocation("/public");
get("/api/users", (req, res) -> userService.getAllUsers(), json());
get("/api/users/:id", (req, res) -> userService.getUser(req.params(":id")), json());
post("/api/users",
(req, res) -> userService.createUser(req.queryParams("name"), req.queryParams("email")),
json());
put("/api/users/:id", (req, res) -> userService.updateUser(
req.params(":id"),
req.queryParams("name"),
req.queryParams("email")
), json());
delete("/api/users/:id", (req, res) -> userService.deleteUser(req.params(":id")), json());
after((req, res) -> {
res.type("application/json");
});
exception(IllegalArgumentException.class, (error, req, res) -> {
res.status(400);
res.body(toJson(new ResponseError(error)));
});
}
代码示例来源:origin: ehcache/ehcache3-samples
staticFileLocation("/public");
代码示例来源:origin: hujiaweibujidao/Ganks-for-gank.io
/**
* 启动服务器
*/
private void startServer() {
CountInfo countInfo = StatTool.count();
//设置端口
if (System.getenv("PORT") != null) {
port(Integer.valueOf(System.getenv("PORT")));
}
//web
staticFileLocation("/public");
//index page
get("/", (request, response) -> {
Map<String, Object> model = new HashMap<String, Object>();
model.put("stat", countInfo);
// The vm files are located under the resources directory
return new ModelAndView(model, "public/html/index.vm");
}, new VelocityTemplateEngine());
//search action
post("/search", (request, response) -> search(request.queryParams("keyword")), new JsonTransformer());
gankHub = new GankHub();
gankHub.startService();
logger.info("server started");
}
代码示例来源:origin: OpenNMS/newts
public static void main(String... args) {
staticFileLocation("/static");
代码示例来源:origin: pyloque/captain
public void start() {
Spark.ipAddress(config.bindHost());
Spark.port(config.bindPort());
Spark.threadPool(config.threadNum());
Spark.staticFileLocation("/static");
if (!config.readonly()) {
this.initWritableHandlers();
}
this.initReadonlyHandlers();
this.initViewHandlers();
this.initExceptionHandlers();
Spark.awaitInitialization();
LOG.warn("captain server started");
}
代码示例来源:origin: iNPUTmice/caas
private static void start() {
staticFileLocation("/public");
webSocket("/socket/*", TestLiveWebsocket.class);
ipAddress(Configuration.getInstance().getIp());
内容来源于网络,如有侵权,请联系作者删除!