Class ViewControllers
java.lang.Object
com.codename1.backend.ViewControllers
- All Implemented Interfaces:
HttpServer.Handler
Routes answered without a controller method, as Spring's
addRedirectViewController and addStatusController.
@Bean
HttpServer.Handler shortcuts() {
return new ViewControllers()
.redirect("/docs", "/docs/index.html")
.status("/favicon.ico", 204);
}
Spring's addViewController("/", "home") -- a template rendered for a
path -- has no counterpart: a view here is compiled into the controller
method that returns it, so there is nothing to look a view name up in at
run time. A one-line @GetMapping method returning the name does the same
and keeps the template checked at build time.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionhandle(HttpServer.Request request) Answerspathwith a 302 tolocation.Answerspathwithstatus(a 3xx) andlocation.Answerspathwithstatusand no body.
-
Constructor Details
-
ViewControllers
public ViewControllers()
-
-
Method Details
-
redirect
Answerspathwith a 302 tolocation.- Parameters:
path- the path, exactlylocation- where the client is sent; relative or absolute- Returns:
- this
-
redirect
Answerspathwithstatus(a 3xx) andlocation.- Parameters:
path- the path, exactlylocation- where the client is sentstatus- 301, 302, 303, 307 or 308- Returns:
- this
-
status
Answerspathwithstatusand no body.- Parameters:
path- the path, exactlystatus- 100 to 599- Returns:
- this
-
handle
- Specified by:
handlein interfaceHttpServer.Handler
-