Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I should have been a bit more clear. But after several hours last night, I found the answer. First, you'll need a main object like this (or similar):</p> <pre><code>object Sandbox { def main(args: Array[String]) { val server = new Server(3000) val context = new WebAppContext() context.setServer(server) context.setContextPath("/") context.setWar("webapp") server.setHandler(context) try { server.start() server.join() } catch { case e: Exception =&gt; e.printStackTrace() System.exit(-1) } } } </code></pre> <p>Then you'll need a servlet:</p> <pre><code>class Test extends ScalatraServlet with ScalateSupport { get("/") { &lt;html&gt; &lt;body&gt; Hello World &lt;/body&gt; &lt;/html&gt; } } </code></pre> <p>You'll also need a ScalatraBootstrap class in your default package (must be named <code>ScalatraBootstrap.scala</code>:</p> <pre><code>class ScalatraBootstrap extends LifeCycle { override def init(context: ServletContext) { context.mount(new Test, "/test/*") } } </code></pre> <p>Almost done. You will need a single XML file. Create a <code>webapp/WEB-INF</code> folder and put this <code>web.xml</code> file in there.</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"&gt; &lt;listener&gt; &lt;listener-class&gt;org.scalatra.servlet.ScalatraListener&lt;/listener-class&gt; &lt;/listener&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;default&lt;/servlet-name&gt; &lt;url-pattern&gt;/img/*&lt;/url-pattern&gt; &lt;url-pattern&gt;/css/*&lt;/url-pattern&gt; &lt;url-pattern&gt;/js/*&lt;/url-pattern&gt; &lt;url-pattern&gt;/assets/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;/web-app&gt; </code></pre> <p>Finally, you'll need the JAR files. There's a pretty long list, but there's a fairly simple way to get them. I hate Maven, but I love the dependency management. So create a test folder somewhere and download the <code>pom.xml</code> file in <a href="https://github.com/Srirangan/scalatra-maven-prototype" rel="nofollow">this</a> repo. Then go to the folder where the <code>pom.xml</code> is and run <code>mvn dependency:copy-dependencies</code>. Grab the JARs from the <code>dependencies</code> folder and you're good to go. No Maven, no SBT, no magic. Run and debug in your IDE like you always do. :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload