【问题标题】:Spring ROO - Generate jsp files directly instead of jspx templatesSpring ROO - 直接生成 jsp 文件而不是 jspx 模板
【发布时间】:2019-01-24 06:31:52
【问题描述】:

我对 spring-roo 比较陌生 我想让roo直接生成jsp文件而不是jspx文件。

我的最终目的是使用 scriplets 修改 roo 生成的 JSP 文件(尽管这不是最佳实践),由于某些特定于我的项目的原因,我想使用 scriplets。

提前感谢您的回答。

【问题讨论】:

    标签: jsp spring-roo auto-generate jspx


    【解决方案1】:

    我没能找到让ROO 生成jsp 的方法。 但按照我的最终意图,我能够使用 scriplets 编辑 ROO 生成的 jspx 文件。

    下面是我用来在 JSPX 页面中添加类似 scriplet 的代码。

    在编辑 Spring-Roo 创建的模板页面时,代码也可以工作。

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <div xmlns:c="http://java.sun.com/jsp/jstl/core"
        xmlns:fn="http://java.sun.com/jsp/jstl/functions"
        xmlns:jsp="http://java.sun.com/JSP/Page"
        xmlns:spring="http://www.springframework.org/tags"
        xmlns:util="urn:jsptagdir:/WEB-INF/tags/util" id="footer" version="2.0">
        <jsp:directive.page contentType="text/html;charset=UTF-8" />
        <jsp:output omit-xml-declaration="yes" />
    
    
        <jsp:declaration> String t; </jsp:declaration>
        <jsp:scriptlet> 
        <![CDATA[
            t="Declared and Initialized From Scriplet";
        ]]>
        </jsp:scriptlet>
    
    
        <jsp:scriptlet> 
        <![CDATA[
        for(int i=0;i<3;i++){
        ]]>
        </jsp:scriptlet>
                <jsp:expression>t+i</jsp:expression> <![CDATA[ iteration &nbsp;&nbsp;<br/>]]>
        <jsp:scriptlet> 
        <![CDATA[
        }
        ]]>
        </jsp:scriptlet>
    </div>
    

    注意:jsp:declaration、jsp:scriptlet 和 jsp:expression 的正确组合可以解决问题。

    以下是参考链接:

    How to produce valid HTML with JSPX? (not XHTML)
    
    https://docs.oracle.com/javaee/1.4/tutorial/doc/JSPX3.html
    

    【讨论】:

      猜你喜欢
      • 2012-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-01
      相关资源
      最近更新 更多