alfresco webscript不执行代码

时间:2016-06-01 09:43:50

标签: alfresco alfresco-webscripts

我试图在露天运行基于java的webscript。在我的第一步中,我只想打印" hello world"使用响应输出流。我面临的主要问题是代码没有被执行。我试图在代码中设置断点,但它们不会触发,我只得到普通的ftl。

不能将abstratWebscript响应优先于ftl? 有人能告诉我,我做错了什么,或者这是否是abstractwebscript的自然行为?

这是java类:

package com.beam.gbsprocs.tag.webscript;
import java.io.IOException;
import java.io.PrintWriter;    

import org.springframework.extensions.webscripts.AbstractWebScript;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.extensions.webscripts.WebScriptResponse;

public class GbsprocsTagWebscript extends AbstractWebScript {



  @Override
  public void execute(WebScriptRequest req, WebScriptResponse res)
        throws IOException {

    PrintWriter out = new PrintWriter(res.getOutputStream());

    out.println("hello world");
    out.close();

  }

}

这是描述文件

<webscript>
<shortname>Perform GBSprocs  Tag completion</shortname>
<description>Export gives a json list of posible tag values </description>
<url>/gbsprocs/tag</url>
<authentication>user</authentication>
</webscript>

Bean声明(在版本中添加):

  <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:util="http://www.springframework.org/schema/util"

   xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
   http://www.springframework.org/schema/util
  http://www.springframework.org/schema/util/spring-util-2.5.xsd">

 <bean id="com.beam.gbsprocs.tag.webscript.GbsprocsTagWebscript.get"
    class="com.beam.gbsprocs.tag.webscript.GbsprocsTagWebscript"
      parent="webscript">


 </bean>

</beans>

ftl看起来像:

Hello from ftl.

执行结果: rest client response

1 个答案:

答案 0 :(得分:1)

使用org.springframework.extensions.webscripts.DeclarativeWebScript代替AbstractWebScript

和@override方法 protected Map executeImpl(WebScriptRequest req,Status status,Cache cache),它将您的模型返回给ftl

而且你还需要在课堂上添加bean deffenition

相关问题