Struts2-Thymeleaf3-plugin

Struts2-Thymeleaf3-plugin for Struts2.5.x. This plugin is unofficial plugin.

License

License

Categories

Categories

Leaf Data Databases
GroupId

GroupId

com.github.psyuhen
ArtifactId

ArtifactId

struts2-thymeleaf3-plugin
Last Version

Last Version

1.0.5.1-RELEASE
Release Date

Release Date

Type

Type

jar
Description

Description

Struts2-Thymeleaf3-plugin
Struts2-Thymeleaf3-plugin for Struts2.5.x. This plugin is unofficial plugin.
Project URL

Project URL

https://github.com/psyuhen/struts2-thymeleaf3-plugin/tree/develop/1.0.5.1
Source Code Management

Source Code Management

https://github.com/psyuhen/struts2-thymeleaf3-plugin.git

Download struts2-thymeleaf3-plugin

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.psyuhen/struts2-thymeleaf3-plugin/ -->
<dependency>
    <groupId>com.github.psyuhen</groupId>
    <artifactId>struts2-thymeleaf3-plugin</artifactId>
    <version>1.0.5.1-RELEASE</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.psyuhen/struts2-thymeleaf3-plugin/
implementation 'com.github.psyuhen:struts2-thymeleaf3-plugin:1.0.5.1-RELEASE'
// https://jarcasting.com/artifacts/com.github.psyuhen/struts2-thymeleaf3-plugin/
implementation ("com.github.psyuhen:struts2-thymeleaf3-plugin:1.0.5.1-RELEASE")
'com.github.psyuhen:struts2-thymeleaf3-plugin:jar:1.0.5.1-RELEASE'
<dependency org="com.github.psyuhen" name="struts2-thymeleaf3-plugin" rev="1.0.5.1-RELEASE">
  <artifact name="struts2-thymeleaf3-plugin" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.psyuhen', module='struts2-thymeleaf3-plugin', version='1.0.5.1-RELEASE')
)
libraryDependencies += "com.github.psyuhen" % "struts2-thymeleaf3-plugin" % "1.0.5.1-RELEASE"
[com.github.psyuhen/struts2-thymeleaf3-plugin "1.0.5.1-RELEASE"]

Dependencies

compile (5)

Group / Artifact Type Version
org.apache.struts : struts2-core jar 2.3.32
org.thymeleaf : thymeleaf jar 3.0.5.RELEASE
org.thymeleaf : thymeleaf-spring4 jar 3.0.5.RELEASE
org.springframework : spring-context jar 4.3.8.RELEASE
org.springframework : spring-web jar 4.3.8.RELEASE

provided (1)

Group / Artifact Type Version
javax.servlet : javax.servlet-api jar 3.1.0

Project Modules

There are no modules declared in this project.

Struts2-Thymeleaf3-plugin

Maven Central

This project is Struts2-plugin for use Thymeleaf templating engine version 3.0.0-RELEASE.

This project fork from Struts2-thymeleaf-plugin, Steven Benitez.

Example Usage

The examples below show you how to map an action's result to a Thymeleaf template, as well as how to reference the Struts2 action from within the template.

Sample and Blank app.

https://github.com/A-pZ/struts2-thymeleaf3-sampleapp/

Action Mapping

<action name="home" class="com.example.HelloWorldAction">
    <result name="success" type="thymeleaf">/WEB-INF/templates/hello.html</result>
</action>

Action Class

public class HelloWorldAction extends ActionSupport {
  private String message;

  @Override
  public String execute() throws Exception {
    message = "Hello, this is a Thymeleaf example!";

    return SUCCESS;
  }

  public String getMessage() {
    return message;
  }
}

Thymeleaf Template

You can refer to properties on the action using the ${action.property} syntax. The following template displays the message property of the action.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <title>Hello World</title>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
</head>

<body>

<p th:text="${message}">This message is only seen during prototyping.</p>

</body>

</html>

Message Resolution

This plugin will cause Thymeleaf to look in the Struts2 i18n resource bundles to resolve messages.

Configuration

The following reflects the default settings (struts.xml). If you changed this values, overwriting your configulation files , struts.xml or struts.properties.

<constant name="struts.thymeleaf.templateMode" value="HTML5"/>
<constant name="struts.thymeleaf.encoding" value="UTF-8"/>
<constant name="struts.thymeleaf.prefix" value="/WEB-INF/templates/"/>
<constant name="struts.thymeleaf.suffix" value=".html"/>
<constant name="struts.thymeleaf.cacheable" value="true"/>
<constant name="struts.thymeleaf.cacheTtlMillis" value="3600000"/>
<constant name="struts.thymeleaf.templateEngineName" value="default"/>

And parent-package set.

<package name="your-app-default" abstract="true" extends="struts-thymeleaf">

or Struts2-convention-plugin annotation.

@ParentPackage("struts-thymeleaf")

Type Conversion Errors support.

This version support Struts2 Type conversion errors. sth:value can response String field, this plugin provided field-error stylesheet class and field value.

Code example :

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:th="http://www.thymeleaf.org"
 xmlns:sth="http://serendip.thymeleaf">
 ...
 <input name="name" type="text" value=""
  sth:value="${name}" error-css="field-error-color" />
 ...
</html>

Spring framework support

This plugin can provide accessibility for spring beans, and Struts2-Spring plugin support. If you use Struts2-Spring plugin and AspectJ, you need change struts.properties below.

How to use Spring Bean

  • use result type : thymeleaf-spring
  • in html template : ${beans.[BeanName]}
  • struts.properties : struts.thymeleaf.templateEngineName=spring

How to use Type conversion support field.

use this namespace : sth this diarect supported value and errorclass such as thymeleaf spring support.

License

Copyright 2016 A-pZ ( Koji Azuma )
Original version is Steven Benitez.(org.codework) 2013.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Versions

Version
1.0.5.1-RELEASE