简体   繁体   中英

How to use Wicket to render html without a servlet engine or web.xml?

I need to create a bunch of html mails with Wicket. But afaik Wicket requires a servlet context.

So I'm looking for a way to use Wicket as a simple renderer for html. That is, render my Page objects, without having to start up a servlet engine.

In essence:

 String renderPageToHtml (Page page) { 
     /* 
        1. Instantiate wicket. 
        2. Render page to String
        3. Return it.
      */
 }

Not tested it, but you might try the WicketTester . This class is actually for resting, but allows to instantiate Components without a servlet container.

WicketTester tester = new WicketTester(new MyApplication();
tester.startPage(MyPage.class);
String MyPageAsString = tester.getLastResponseAsString();

As I said, use at your own risk, I have not tested this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM