I'm new to Java and Vaadin. A basic Vaadin project is using web.xml
for all the mappings. If I want to use the @WebServlet
annotation I need to create an inner class which somewhere inherits from HttpServlet
.
@SuppressWarnings("serial")
public class VaadinplaygroundUI extends UI {
@WebServlet(urlPatterns="/Helo")
public static class Servlet extends VaadinServlet {
}
@Override
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
I know, I'm missing some overwritten methods in the inner class Servlet
to get it working, but I don't know which. There are many examples in the internet for Vaadin 6.x where the inner class extends AbstractApplicationServlet
.
Thanks for any help.
Here's for 7.x:
public class MyUI extends UI {
@WebServlet(value = "/*", asyncSupported = true, initParams = {
@WebInitParam(name = "ui", value = "com.example.MyUI"),
@WebInitParam(name = "productionMode", value = "false") })
public static class Servlet extends VaadinServlet {
}
@Override
protected void init(VaadinRequest request) {
..
}
}
And for 7.1 and newer:
public class MyUI extends UI {
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = MyUI.class)
public static class Servlet extends VaadinServlet {
}
@Override
protected void init(VaadinRequest request) {
..
}
}