最佳答案
我还没有看到任何能够满足您要求的好插件.
原文链接:https://www.f2er.com/spring/432264.html作为替代方案,您可以将jetty服务器的jar放到类路径中(我使用jetty-6.1.5.jar和jetty-util-6.1.5.jar)并编写如下所示的类.
package net.eduportal.jetty;
import javax.servlet.ServletContext;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.security.UserRealm;
import org.mortbay.jetty.webapp.WebAppContext;
public class JettyRunner {
public static final int PORT = 8080;
public static final String BASE_URL = "http://localhost:" + PORT;
private static final JettyRunner _instance = new JettyRunner();
public static JettyRunner getInstance() {
return _instance;
}
// ///////////////////////////////////////////////////////////////
// Singleton
// /////////////
private Server server = null;
private WebAppContext wac = null;
private JettyRunner() {
}
public interface WebApplicationInitializer {
public void init(WebAppContext wac);
}
public ServletContext getServletContext() {
return wac.getServletContext();
}
public void start() throws Exception {
if (server == null) {
server = new Server(PORT);
server.setStopAtShutdown(true);
wac = new WebAppContext();
wac.setContextPath("/test");
wac.setResourceBase("war");
wac.setClassLoader(this.getClass().getClassLoader());
server.addHandler(wac);
server.start();
}
}
public void stop() throws Exception {
if (server != null) {
server.stop();
server = null;
}
}
public static void main(String argv[]) throws Exception {
JettyRunner.getInstance().start();
}
}
上面的代码假设类路径中有一个名为“war”的文件夹,其中包含相同的WEB-INF / *文件夹.当您从eclipse运行代码时,服务器将启动,您可以通过访问localhost:8080 / test / *来查看jsps