好,所以我採取了暴跌,試圖看看這整個事情是如何工作的。事實證明相當簡單。下面是步驟,有興趣的人:
Maven的POM依賴關係:
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>${scala.version}</version>
</dependency>
<!-- scalate templating engine -->
<dependency>
<groupId>org.fusesource.scalate</groupId>
<artifactId>scalate-spring-mvc</artifactId>
<version>${scalate.version}</version>
</dependency>
<dependency>
<groupId>org.fusesource.scalate</groupId>
<artifactId>scalate-wikitext</artifactId>
<version>${scalate.version}</version>
</dependency>
<dependency>
<groupId>org.fusesource.scalate</groupId>
<artifactId>scalate-page</artifactId>
<version>${scalate.version}</version>
</dependency>
<dependency>
<groupId>org.fusesource.scalamd</groupId>
<artifactId>scalamd</artifactId>
<version>${scalamd.version}</version>
</dependency>
<dependency>
<groupId>org.fusesource.scalate</groupId>
<artifactId>scalate-test</artifactId>
<version>${scalate.version}</version>
<scope>test</scope>
</dependency>
MVC-servlet.xml中:
<bean id="viewNameTranslator" class="org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator"/>
<bean id="scalateViewResolver" class="org.fusesource.scalate.spring.view.ScalateViewResolver"
p:order="1" p:prefix="/WEB-INF/view/" p:suffix=".scaml" />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:order="2" p:viewClass="org.springframework.web.servlet.view.JstlView" p:prefix="/WEB-INF/view/" p:suffix=".jspx" />
於是我改名一些JSPX並開始轉換代碼。要訪問模型對象我這樣做,我scaml文件的頂部:
[email protected] var x:String
[email protected] var y:List[com.xxx.model.MyModelObject]
然後我就跟着scaml文檔。超級簡單。唯一令人尷尬的是試圖把內聯的JavaScript ......它抱怨縮進或什麼。所以我把它移到了一個單獨的文件中。
根本沒有必要刪除sitemesh(但我可以在將來每當我準備好時),我可以在閒暇時遷移jspx文件。再簡單不過了。