Custom template engine for struts2

I want to create my own template engine , for example speed or freemarker , which will be used in an application based on struts 2. Why I do not want to use any of the available template engines, because I want the HMTL to be fixed and editable with Dreamweaver, does not mean that location tags or JSTLs are missing. Values โ€‹โ€‹will be entered using Xpath or simply replacing the string of values โ€‹โ€‹of existing HTML tags. I need:

plain HTML + some configuration (/ xml properties) + data =>

HTML populated with data + some dynamically generated javascripts

+1
source share
1 answer

1) Define a package with the name of your result type and the class that will be called when the action returns this result type.

<package name="default" namespace="/" extends="struts-default">
  <result-types>
    <result-type name="myResultType" class="com.awesome.MyResult"/> 
  </result-types>
  .... actions and other things...
</package>

2) Introduce the result type class Struts 2:

package com.awesome;
public class MyResult extends StrutsResultSupport{
  //1) read the the target file
  //2) process/transform the target file
  //3) write out the transformed file as the result
} 

This is a good description of this in Dave Newton's Apache Struts 2 Web Application Development. I know this class is not implemented, but I'm sure you can find what you need from here.

+2
source

Source: https://habr.com/ru/post/1715794/


All Articles