How to Convert Struts tags to Jstl/Spring

 


Here is an example to convert struts tags to jstl and spring tags.Here is an list of struts tags and equivalent tags in JSTL and Spring.

1.Tags:

1.html

html:select form:select
html:option form:option
html:options form:options
html:hidden form:hidden
html:checkbox form:checkbox
html:multibox form:checkboxes
html:text form:input
html:textarea form:textarea
html:form form:form
html:errors form:errors
html:radio form:radiobutton

2.bean

bean:write c:out
bean:define c:set
bean:message spring:message

3.logic

logic:present c:if
logic:notPresent c:if
logic:iterate c:forEach
logic:equal c:if (test eq)
logic:notEqual c:if (test ne)
logic:empty c:if (test empty)
logic:notEmpty c:if (test not empty)

But the problem is we have to change manually in JSP files, so i created an tool which uses jsoup and Apache commons to automatically process and overwrite tags.This tool reads all tags in JSP files and process overwriting to JSTL or Spring tags.Below is an sample code to process using java.


  private static void processHtmlHiddenTag(Element element)
	{
		String name = element.attr("name");
		String property = element.attr("property");

		if(!isEmptyOrNull(name) || isEmptyOrNull(property))
			return;

		element.tagName("form:hidden");
		element.attr("path",property);
		element.removeAttr("property");
	}
    
    

Check out on GitHub for full code Click Here..