これが ICM 7.7 で機能することはわかっていますが、7.4 以降は存在していたと思います。
Guice Servlet Extensionを使用できます。
1. カートリッジ内の Guice サーブレットへの依存関係を宣言しますbuild.gradle
。例:
dependencies
{
...
compile group: 'com.intershop.platform', name: 'servletengine'
compile 'com.google.inject.extensions:guice-servlet'
...
}
2.カートリッジにサーブレットモジュールを定義しますobjectgraph.properties
。例:
global.modules = com.example.modules.DemoServletModule
3.サーブレットを実装します。例:
public class DemoServlet extends HttpServlet
{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
resp.getWriter().append("Hello, world!");
}
}
4.モジュールの実装を作成します。注意点:名前は/servlet/
、コメントで指摘されているとおりに開始する必要があります。例:
import javax.inject.Singleton;
import com.google.inject.servlet.ServletModule;
public class DemoServletModule extends ServletModule
{
@Override
protected void configureServlets()
{
bind(DemoServlet.class).in(Singleton.class);
serve("/servlet/DEMO/*").with(DemoServlet.class);
}
}
4.ビルド、再起動、試す。例:
GET /servlet/DEMO/hey HTTP/1.1
Host: example.com:10054
....
応答:
Hello, world!
アップデート:
サーブレットが webadapter を介して表示されるようにする場合は、それを許可する必要があります。
1.開くIS_SHARE\system\config\cluster\webadapter.properties
2. このセクションに移動します。
## The list of servlets, which can be accessed through the generic
## .servlet mapping. The WebAdapter forwards only requests of the form
## /servlet/<group><servlet.allow.x>...
3.サーブレットのエントリを追加します。例:
servlet.allow.4=/DEMO
4. 同様の URL でサーブレットにアクセスします。
https://example.com/INTERSHOP/servlet/WFS/DEMO/hey