As the title says, I have a page template in the background, which contains some places where specific data needs to be filled in. I call a method to pass in the template file and context object, and then return an assembled page html code. May I ask what technology is more convenient to implement this? I have consideredSpring's EL expression
andJava EE's JSTL
, but I think it is not very useful. It would be best if you could give me a simple example.
template:
Spring EL Test
Hello, ${user.name}!
It is possible to call such a method
String result = parse(File file, Object contextObj); // 得到组装后数据
Data after assembly:
Spring EL Test
Hello, ZhangSan!
First of all, let me correct you. EL expressions are not provided by Spring, but by JSP 2.x.
The so-called assembly means using
request.setAttribute()
设一个名为user
objects to parse the objects in jsp.This should be enough: