Learn about spring mvc velocity email template example, we have the largest and most updated spring mvc velocity email template example information on alibabacloud.com
Spring MVC integrated Velocity template
Spring MVC
We used struts2 when using the traditional configuration file in a way that did not use the legendary 0 configuration. SPRING3 MVC ca
sending mail in spring is an easy task, and it's much easier to send it using velocity as a template for mail. First of all, or simply describe the configuration in sping, send mail needs a mail engin:class= "Com.aodragon.jdt.backend.service.impl.MailEngineImpl" > The following classes are implemented: PackageCom.aodragon.jdt.backend.service.impl;ImportJava.util.
In the previous article we covered the content of the velocity template engine, and below we describe how to use velocity in spring mvc.
--------------------------------------------------------------------------------------------------------------- --------------------------
Velocity is a Java-based template engine in Apache. the simple use of this Apache velocity template engine can better separate style design from Java development.
For example, when sending emails to some customers, the mail body usually contains some standardized forms or l
Spring MVC consolidates the velocity to introduce the packages that need to be imported, such asPom Introduction:Then, is a very simple configuration, then, here, modify the next spring-mvc.xml content, the content is modified as followsXML version= "1.0" encoding= "UTF-8"?>See below the beans this element tag does not
Spring MVC version 4.1.6.RELAESE is used in recent projects And Velocity-tools was upgraded to 2.0 by my 2B. ------------------------------ Where the MVC 3 version requires custom Viewclass to complete the velocity tools loading, or error This step, online already someone sh
Next to the previous response
When spring MVC integrates velocity, it is necessary to introduce related packages. The packages to be imported are as follows:
Then, it is very simple configuration, then here, modify the content of the springMvc-servlet.xml, the content is modified as follows
Then create the velocity.
Simple email sending example by MVC and email sending example by mvc
Let's talk about Code directly.
1 @ {2 try 3 {4 WebMail. smtpServer = "smtp.qq.com"; // SMTP Mail Server 5 WebMail. smtpPort = 25; // sending port 6 WebMail. e
1. Load the velocity expansion package to the project first via Pom.xml:1 Dependency>2 groupId>VelocitygroupId>3 Artifactid>VelocityArtifactid>4 version>1.5version>5 Dependency>2. Then add the following configuration in the XML that automatically loads the bean:1 BeanID= "Velocityconfig"2 class= "Org.springframework.web.servlet.view.velocity.VelocityConfigurer">3 Propertyname= "Resourceloaderpath"value= "/web-inf/views/" />4 Prop
(Do not use this template, the latest version of spring boot is not supported.) Use Freemarker bar: http://blog.csdn.net/clementad/article/details/51942629)
In a few simple steps, use the velocity template to generate text in spring boot:
1. Introduction of Dependency
Velocity Seventh Application Example----Assignment in a template
2 Create a context Objectvelocitycontext context = Newvelocitycontext ();//3 Add you data object to this CONTEXTCONTEXT.P UT ("name", "Old Bi");//4 Choose a templatetemplate template =velocity.gettemplate ("TEMPLATE7.VM");//5 Merge the
In a few simple steps, implement the use of the velocity or freemarker template to construct the page in spring boot and return to the front end:
1. Introduce dependencies and create templates directory:
velocity:http://blog.csdn.net/clementad/article/details/51819647
freemarker:http://blog.csdn.net/clementad/article/details/51942629
2. Create
a java directory,
└── src └── main └── java └── webappPackage org. webmvc. controller;
@Controllerpublic class HomeController{ @RequestMapping("/home") public String showHomePage(Model model){ model.addAttribute("name","spring-mvc"); return "home"; }}
To achieve automatic detection and assembly, we add the following in the configuration file:
The following
First create a new WebApp folder under src/main/Idea and then click File–>project Structure–>modules->boot-mybatis-mvc to add support for Web projects, as shown in figure:
Add Spring Context support
Added applicationcontext.xml and application.properties files under Src/main/resources, and added spring-mvc.xml MVC un
Maven Project Build spring boot + spring mvc + JPA example, mavenmvc
This article describes how to build spring boot + spring mvc + JPA by using Maven:
Add
This template is basically prepared as follows: spring 3.1.2 + velocity 1.7 + hibernate 4.1.7 + mysql 5.1
Due to the upload restrictions, all jar packages are removed from the archive. Please add and download the packages by yourself.
Jar package list
Antlr-2.7.7.jarC3p0-0.9.1.2.jarcommons-beanutils-1.7.0.jarcommons-collections-3.1.jarcommons-digester-1.8.jarcom
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.