unfilteredで作ったアプリをtomcatで動かす
手順
unfilteredでアプリを作る
"Hello"って返すだけのアプリを作ります。
Unfiltered では Plan ってのを作って URL のルーティングをします。
package com.github.tototoshi.unfiltered_example import unfiltered.request._ import unfiltered.response._ import unfiltered.filter._ class HelloApp extends Plan { def intent = { case _ => ResponseString("Hello") } }
web.xmlを書く
作った Plan を FIlter に指定してください。
Plan は Filter を継承しています。
<?xml version="1.0" encoding="utf8"?> <!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> <filter> <filter-name>App</filter-name> <filter-class>com.github.tototoshi.unfiltered_example.HelloApp</filter-class> </filter> <filter-mapping> <filter-name>App</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
xsbt-web-pluginでwarにする
siasia/xsbt-web-plugin · GitHubのプラグインを入れれば
sbt package で jar ではなく war ができるようになります。