在Maven项目中以嵌入模式配置Jetty JSP支持
我可以使用 Jetty 访问 .html 页面,但是当我访问 .jsp 页面时,我得到:
0 13:21:13 / [INFO] 不支持 JSP。 检查 JSP jar 是否位于 lib/jsp 中并且 已指定 JSP 选项 启动.jar
我添加了以下内容作为依赖项:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>8.0.0.M1</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
</dependency>
这是否满足错误消息的“检查 JSP jar 是否在 lib/jsp 中”部分?
另外,我不知道“检查 JSP 选项是否已指定为 start.jar”在这种情况下意味着什么。我有以下内容:
public static void main(String[] args) throws Exception {
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(8080);
server.addConnector(connector);
WebAppContext webApp = new WebAppContext();
webApp.setContextPath("/");
webApp.setWar("src/main/webapp");
server.setHandler(webApp);
server.start();
server.join();
}
I can visit .html pages with Jetty, but when I visit a .jsp page I get:
0 13:21:13 / [INFO] No JSP support.
Check that JSP jars are in lib/jsp and
that the JSP option has been specified
to start.jar
I added the following as dependencies:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>8.0.0.M1</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
</dependency>
Does that fulfill the "check that JSP jars are in lib/jsp" part of the error message?
Also, I have no idea what "check that the JSP option has been specified to start.jar" means in this context. I have the following:
public static void main(String[] args) throws Exception {
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(8080);
server.addConnector(connector);
WebAppContext webApp = new WebAppContext();
webApp.setContextPath("/");
webApp.setWar("src/main/webapp");
server.setHandler(webApp);
server.start();
server.join();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我通过添加 Mortbay JSP 依赖项(这是 Gradle 表示法,但你明白了)来让它工作:
有一个 我的博客上有更大的文章。
I got it to work by adding the Mortbay JSP dependency (this is in Gradle notation, but you get the idea):
There's a larger writeup available on my blog.
我没有使用 Jetty 发行版中的 jar,仅使用 Maven 依赖项来完成此操作:
I have done it without using the jars from the Jetty distribution, using only Maven dependencies:
我知道这个问题不久前已经得到了回答。我无法从为我工作的本·麦肯那里得到答案。然而,我很幸运,通过添加直接向 Jetty 添加 JSP 支持,
奇怪的是,我最初的 6.1.24 版本不支持此功能。
总的来说,我的 pom.xml 看起来像这样:
和我的开始类(我在文件夹
\src\test\java\com\company\wikiproject
中添加)I know this has been answered a while ago. I could not get the answer from Ben McCann to work for me. However, i had luck by adding JSP support directly to Jetty by adding
Strangely, this was not supported by the version 6.1.24 I originally had.
So in total, that made my pom.xml look like this:
and my start class (which i added in folder
\src\test\java\com\company\wikiproject
)基于 Simon Huet 的出色回答,我的看法如下:
Building upon Simon Huet's excellent answer, here's my take:
阅读此 stackoverflow 页面(干得好)以及 http://wiki.eclipse.org/Jetty 后/Howto/Configure_JSP,我终于让它也能工作了。由于我的配置略有不同,我想我会做出贡献。我有一个没有“javac”编译器的嵌入式 Jetty 8 安装,我通过使用 eclipse 编译器并在创建服务器之前设置系统属性来使其工作,如下所示:
并使用以下 Maven 配置:
After reading this stackoverflow page (nice job) as well as http://wiki.eclipse.org/Jetty/Howto/Configure_JSP, I finally got this to work as well. Since my config is slightly different, I thought I'd contribute back. I have an embedded Jetty 8 installation without the 'javac' compiler, and I got it to work by using the eclipse compiler and setting the system property before creating the server, like this:
And using the following maven configuration:
Jetty 9.1.3,http://www.eclipse.org/jetty/ Documentation/current/configuring-jsp.html,并且仅添加 jetty-jsp 对我有用(加上网址中的 web.xml 配置)。无需从码头 groupId 外部(即 mortbay)添加 jar。
Jetty 9.1.3, http://www.eclipse.org/jetty/documentation/current/configuring-jsp.html, and just adding jetty-jsp worked for me (plus the web.xml config from the url). No need to add jars from outside the jetty groupId (ie. mortbay).