Java web 基於spring-2m的jetty配置

.classpath:
<classpathentry kind="output" path="WebContent/WEB-INF/classes"/

修改輸出路徑:
<classpathentry kind="output" path="WebContent/dateView/WEB-INF/classes"/>

新增的依賴jar:
jasper-compiler.jar
jasper-runtime.jar
javax.servlet.jar
org.mortbay.jetty.jar
org.mortbay.jmx.jar
tomcat-juli.jar

JettyLauncher.java:
import org.mortbay.http.SocketListener;
import org.mortbay.jetty.Server;

public class JettyLauncher {
	protected int port = 8081;
	protected String contextName = "dateView";
	protected String deployPath = "";
	
	public static void main(String[] args) throws Exception {
		JettyLauncher jl = new JettyLauncher();
		jl.init();
		jl.run();
	}
	
	protected void init() {
	}
	
	protected void run() throws Exception {
		Server server = new Server();
		SocketListener listener = new SocketListener();
		listener.setPort(getPort()); 
		server.addListener(listener);
		server.addWebApplication("/" + getContextName() , getDeployPath());
		server.start();
	}
	
	protected int getPort() {
		return port;
	}
	
	protected String getContextName() {
		return contextName;
	}
	
	protected String getDeployPath() {
		if (deployPath.length() == 0) {
			deployPath = "./WebContent/" + contextName + "/";
		}
		return deployPath;
	}
}

項目截圖:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章