gpt4 book ai didi

java - 无法让 freemarker 模板在 reSTLet 上运行,所使用的协议(protocol)未在客户端连接器中声明

转载 作者:行者123 更新时间:2023-12-02 00:32:07 24 4
gpt4 key购买 nike

我正在尝试传递我的 ftl 模板的位置。

在 MyApplication 中扩展应用程序

我已经尝试过了......

getConnectorService().getClientProtocols().add(Protocol.FILE);

我什至尝试过这个分散......

ConnectorService cs =new ConnectorService();
cs.setClientProtocols(UtilMisc.toList(Protocol.FILE, Protocol.HTTP));
setConnectorService(cs);

@Override
public Restlet createInboundRoot() {
//I even added this in to get it to print out which had been set and they were in there!
for(Protocol p :getConnectorService().getClientProtocols()){
Debug.log(p.getName());
}

// initialize the Freemarker's configuration
configuration = new Configuration();
configuration
.setTemplateLoader(new ContextTemplateLoader(
getContext(),
"file:/D:/development/myexample/deploy/myexample-integrations/webapp/myexample-base/service"));

然后我的 HtmlRepresentationHandler 中有这个......

    String templateName = "serviceInfo.ftl";
MediaType mediaType = MediaType.APPLICATION_XHTML;
TemplateRepresentationrep = new TemplateRepresentation(templateName, getApp().getConfiguration(), cleanServiceResultMapInstance(results), mediaType);

我总是遇到同样的错误,我什至尝试了其他协议(protocol)但无济于事。

Jan 8, 2012 4:45:58 AM org.restlet.engine.component.ClientRouter getNext
[java] WARNING: The protocol used by this request is not declared in the list of client connectors. (FILE)
[java] WARNING: Unable to get the template serviceInfo.ftl. Error message: Template serviceInfo.ftl not found.

最佳答案

我记得也曾为此奋斗过here .

解决方案最终是在应用程序的 servlet 参数中声明客户端协议(protocol):

  <servlet>
<init-param>
<param-name>or​g.restlet.clients​</param-name>
<param-value>HTTP HTTPS FILE</param-value>
</init-param>
</servlet>

另请参阅javadoc

关于java - 无法让 freemarker 模板在 reSTLet 上运行,所使用的协议(protocol)未在客户端连接器中声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8771699/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com