FreeMarker template error! in struts2

FreeMarker template error! in struts2

By : user2956247
Date : November 22 2020, 10:54 AM
I wish this help you The exception is telling you exactly where to look for the error:
code :
<s:textfield id="full_name" name="full_name" ... />
<s:fielderror fieldName="full_name" cssClass="alert-danger"/>
<s:fielderror fieldName="fullName" cssClass="alert-danger"/>
<property name="hibernate.ejb.naming_strategy"
         value="org.hibernate.cfg.ImprovedNamingStrategy" />

Share : facebook icon twitter icon
Getting template text from FreeMarker in Struts2 app

Getting template text from FreeMarker in Struts2 app

By : user2389751
Date : March 29 2020, 07:55 AM
To fix this issue I would like to generate email inside a Struts2 application, using Freemarker. As I am also using Freemarker for my view, I would like to "reuse" the same config. , Something like this should do,
code :
import com.opensymphony.xwork2.ActionSupport;
import freemarker.template.Configuration;
import freemarker.template.Template;

import java.io.StringWriter;

import javax.servlet.ServletContext;

import org.apache.struts2.util.ServletContextAware;
import org.apache.struts2.views.freemarker.FreemarkerManager;

public class DummyAction extends ActionSupport implements ServletContextAware
    private static final long serialVersionUID = 1L;
    private ServletContext context;

    public String execute()
            //retrive freemarker config used by struts2 for freemarker results
            FreemarkerManager manager = new FreemarkerManager();
            Configuration cfg = manager.getConfiguration(context);
            Template template = cfg.getTemplate("your-template");

            //your data model
            Object root = new Object();

            //process template
            StringWriter out = new StringWriter();
            template.process(new Object(), out);

            String renderedText= out.toString();


        } catch (Exception e)

        //do work

        return "success?";

    public void setServletContext(ServletContext context)
        this.context = context;
struts2 and freemarker template

struts2 and freemarker template

By : Melniu
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further i use struts2 on my web app, in one jsp file i display 3 arraylist in a form using "iterator". ,
Could not find template in cache
code :
<constant name="struts.ui.templateDir" value="templates" />
<constant name="struts.ui.theme" value="simple" />
freemarker error: expected hash. evaluated instead to freemarker.template.SimpleScalar

freemarker error: expected hash. evaluated instead to freemarker.template.SimpleScalar

By : hgmalaca
Date : March 29 2020, 07:55 AM
Does that help With <#assign senti = "${scmr.results[model]}"> you have converted scmr.results[model] to a String (a scalar), that's why. Just write <#assign senti = scmr.results[model]>. In FreeMarker expressions you can inject value into a string literal, like "Hello ${name}!" (same as "Hello " + name + "!"), and "${someExpression}" is just a case of that. It's not like in JSP.
Freemarker template (FTL) not working in struts2

Freemarker template (FTL) not working in struts2

By : JSJoe
Date : March 29 2020, 07:55 AM
I hope this helps you . I am working with Struts2 and ftl. Instead of jsp I want to use ftl, but when I define welcome file in web.xml as login.ftl it is not working. It just shown as text. The entire code is shown in the browser, but if it is jsp everything works. , Maybe this help you(extract of a web.xml):
code :

  <!-- FreemarkerServlet settings: -->

  <!-- FreeMarker settings: -->
    <param-value>0</param-value> <!-- 0 is for development only! Use higher value otherwise. -->


<!-- Action Servlet Mapping -->

<!-- Map *.ftl files to Freemarker-->

<!-- The Welcome File List -->
I am not using freemarker for struts2, but I see lots of logging generated by freemarker

I am not using freemarker for struts2, but I see lots of logging generated by freemarker

By : scott
Date : March 29 2020, 07:55 AM
hop of those help? Struts2 uses THEMEs to generate code from Struts tags;
a THEME is a collection of TEMPLATEs (one for each tag);
Related Posts Related Posts :
  • Forcefully terminating a thread I didn't write in Java
  • Issue with ojdbc jar in Maven
  • String array length java
  • Java basic compilation error
  • Inquiry about writing a Char via ByteBuffer
  • Getting unexpected results when type casting between long and double
  • Variable throws variable might not have been initialized error
  • Start/stop java application from an external script
  • Confusion in declaring String Objects
  • What are some ways to do multi-core programming on Android, not just multi-thread?
  • hibernate - process scoped identity
  • Null Pointer Exception on getGraphics()
  • Can we print a java message on console without using main method, static variable and static method?
  • sending text from editText to ListView (2 activities)
  • Transfer value from JList to another class in Java
  • Creating 2 streams with one socket
  • How measure time stolen from virtual machine, in Scala/Java?
  • How can I programmatically generate keypress events?
  • org.apache.commons.net.ssh documentation
  • Implementation of Dijkstra`s Algorithm - Stuck in an infinite loop
  • Should I throw IllegalArgmentException when 'user of given id not exist'?
  • In Nimbus, how to paint TextField when MouseOver?
  • why won't checkforWin(File f) return true when it is true?
  • Android: Cursor is always returning null even if the database is not empty
  • Repeating for loop in menu
  • Can Java garbage collector randomly delete objects in the On-Heap tier?
  • Apache CXF Exception: SSL connection unexpectedly closed
  • Add properties to ArrayList<Object> in Java
  • Multiple Adapters or One Adapter for different lists and objects - Code Performance
  • Is it good practice in Java for a class's method to redundantly return a modified global field of the class?
  • How to change the color of the background in libgdx labels?
  • direct file path not working
  • ClassFileTransformer + Javassist: no such field
  • How do I change and instance variable for an object which the user selects from a combobox?
  • reading and updating a large xml file in java
  • ActionListener and Thread.sleep
  • What is the maximum of number of arguments for varargs in java?
  • When I compile I get an error as "ask" cannot be resolved or is not a field"
  • What is the best way to check if 4 integer variables are equal to 0?
  • Storing constant webdriver elements in an enum
  • Java: Why main class does not extend Thread class
  • Java - how to find out if a directory is being used by another process?
  • How can I get a method to print?
  • Java unknown exceptions
  • BufferedReader,StreamWriter crash
  • found raw type: JComboBox
  • Java Generics -> Function return type
  • how to refresh contents of jtable on event of action listener?
  • Why does List interface extend Collection interface?
  • Pros and Cons of Clojure http client libraries
  • use final inside a for each loop
  • Convert java data object to service object
  • Unsupported major.minor version 51.0 while executing JSP
  • How do I display a word diagonally in Java?
  • making sure one task completes before another starts in java
  • My program gives an index out of bounds error
  • Removing duplicate characters in a String (user inputted keyword)
  • Jersey 2.0 Content-Length not set
  • AWS.SimpleQueueService.NonExistentQueue Exception thrown when Accessing Existing SQS queue
  • Where can I find the source code for the com.sun.jdi package?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org