Add RequestContext to Groovy template view model
This commit is contained in:
parent
f572992c5d
commit
7c7d1f55e0
|
|
@ -24,7 +24,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
|||
* @author Dave Syer
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "spring.groovy.template")
|
||||
@ConfigurationProperties(prefix = "spring.groovy.template", ignoreUnknownFields = false)
|
||||
public class GroovyTemplateProperties {
|
||||
|
||||
public static final String DEFAULT_PREFIX = "classpath:/templates/";
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import java.util.Map;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.web.servlet.support.RequestContext;
|
||||
import org.springframework.web.servlet.view.AbstractUrlBasedView;
|
||||
|
||||
/**
|
||||
|
|
@ -43,6 +44,8 @@ public class GroovyTemplateView extends AbstractUrlBasedView {
|
|||
protected void renderMergedOutputModel(Map<String, Object> model,
|
||||
HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
applyContentType(response);
|
||||
model.put("spring", new RequestContext(request, response, getServletContext(),
|
||||
model));
|
||||
this.template.make(model).writeTo(new BufferedWriter(response.getWriter()));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue