gpt4 book ai didi

java - 如何使用 java servlet 加载动态 url

转载 作者:行者123 更新时间:2023-11-30 07:46:14 25 4
gpt4 key购买 nike

代替*.jsp我需要像 case-58 或 case-appId 那样如果我们看到这种情况 - 意味着需要加载 servlet。在该 servlet 中,我需要重定向到相应的 jsp 文件。像这样我的网络应用程序需要运行。我不知道如何实现这个。任何人有想法的方法请给出解决方案。提前致谢。为了供您引用,我们使用 web.xml 进行 servlet 映射。

最佳答案

您可以使用Guice Filtering

为不同的 servlet 或 jsps 提供不同的案例,不需要使用 web,xml(只需注册一个 Guice 监听器)

public class ServletConfig extends GuiceServletContextListener {
@Override
protected Injector getInjector() {
return Guice.createInjector(new ServletModule() {
@Override
protected void configureServlets() {
super.configureServlets();

serve("/").with(TestServlet.class);
}
});
}

}

http://blog.scottlogic.com/2012/05/31/building-web-services-using-guice.html

关于java - 如何使用 java servlet 加载动态 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33910255/

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