在Maven项目中以嵌入式模式配置Jetty JSP支持 [英] Configuring Jetty JSP support in embedded mode in Maven project
问题描述
我可以使用Jetty访问.html页面,但是当我访问.jsp页面时,我得到:
I can visit .html pages with Jetty, but when I visit a .jsp page I get:
0 13:21:13/[INFO]不支持JSP. 检查JSP jar是否在lib/jsp中,并 已经指定了JSP选项 启动.
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>
是否满足错误消息的检查JSP jar是否在lib/jsp中"部分?
Does that fulfill the "check that JSP jars are in lib/jsp" part of the error message?
此外,在这种情况下,我也不知道检查是否已将JSP选项指定为start.jar"的含义.我有以下内容:
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();
}
推荐答案
我通过添加Mortbay JSP依赖项使其工作(这是Gradle表示法,但是您知道了):
I got it to work by adding the Mortbay JSP dependency (this is in Gradle notation, but you get the idea):
compile 'org.eclipse.jetty:jetty-io:8.0.0.M3'
compile 'org.eclipse.jetty:jetty-server:8.0.0.M3'
compile 'org.eclipse.jetty:jetty-servlet:8.0.0.M3'
compile 'org.eclipse.jetty:jetty-util:8.0.0.M3'
compile 'org.eclipse.jetty:jetty-webapp:8.0.0.M3'
compile 'org.mortbay.jetty:jsp-2.1-glassfish:2.1.v20100127'
我的博客上有一个更大的文章.
这篇关于在Maven项目中以嵌入式模式配置Jetty JSP支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!