I am fighting with ActiveWeb currently. I found, as it seems to me, that it's manual here http://javalite.io/activeweb contains a lot of desinformation.
First it says ActiveWeb is zer-configuration, which is not true. web.xml
is still required. Also configuration in java is required. For example, file AppBootstrap.java
should be present in appropriate location.
Second, I can't find it yet, how to configure views to work.
I have the following controller
package app.controllers;
import java.util.Date;
import org.javalite.activeweb.AppController;
public class GreetingController extends AppController {
public void index() {
}
public void hello() {
view("date", new Date().toString());
view("name", param("name"));
}
}
and it works as I see in debugger. When I open http://localhost:8080/testapp/greeting/hello
, the breakpoint in hello()
method is reached.
Unfortunately, the file hello.ftl
, located in WEB-INF/views/greeting/hello.ftl
is apparently ignored, because the browser output is empty.
Simultaneously, it is 100% empty, i.e. there are no HTTP headers at all. This points to suggestion, that some general config is missing.
Also, I have empty output on EVER query, including
http://localhost:8080/testapp
http://localhost:8080/testapp/greeting
http://localhost:8080/testapp/abracadabra
while some of the requests should return errors or service messages.
Request
http://localhost:8080/
returns 404
which means container is working normally.
My web.xml
is follows:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<filter>
<filter-name>dispatcher</filter-name>
<filter-class>org.javalite.activeweb.RequestDispatcher</filter-class>
<init-param>
<param-name>exclusions</param-name>
<param-value>css,images,js</param-value>
</init-param>
<init-param>
<param-name>root_controller</param-name>
<param-value>home</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>dispatcher</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
UPDATE
When I removed root_controller
parameter from web.xml
, the server started to answer with directory listing on
http://localhost:8080/testapp
Other answers are still completely empty
UPDATE 2
Apparently WEB-INF/views/layouts/default_layout.ftl
should be present. Otherwise the results will be empty and no error will be reported.