Reputation: 139
I'm relatively new to spring-roo I want to make roo generate jsp files directly instead of jspx files.
My final intention is to modify roo generated JSP files by using scriplets (Though it is not the best practice), due to some reasons specific to my project I want to use scriplets.
Thanks in advance for your answers.
Upvotes: 0
Views: 45
Reputation: 139
I was not able to find a way to make ROO generate jsp. But as per my final intention I was able to edit ROO generated jspx files using scriplets.
Below is the code which I used to add scriplet like coding in JSPX pages.
Code also works while editing template pages created by 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 <br/>]]>
<jsp:scriptlet>
<![CDATA[
}
]]>
</jsp:scriptlet>
</div>
Note: Proper combination of jsp:declaration, jsp:scriptlet and jsp:expression along with does the trick.
Following are reference links:
How to produce valid HTML with JSPX? (not XHTML)
https://docs.oracle.com/javaee/1.4/tutorial/doc/JSPX3.html
Upvotes: 0