내 Intellij 13.1.4에서 "restlet-2.2"프레임 워크를 사용하는 JAVA-EE 프로젝트가 있습니다.Intelij에서 Restlet 웹 프로젝트를 Apache Tomcat에 배포 하시겠습니까?
이 프로젝트를 아파치 톰캣 서버에 배포하고 싶지만 몇 가지 문제가 있습니다.
프로젝트 구조
1. 기본적으로 다른 웹 서비스 인 일부 JAVA 클래스가 있습니다. 이 클래스들은 모두 ServerResource 클래스를 확장합니다. 이 클래스에는 @Get 메서드가있어 클라이언트 요청에 응답합니다.
2.Then 나는 클래스 MyServer를 응용 프로그램 클래스를 확장을 가지고 MyServer를 내가 적절한 웹 서비스에 기본적으로 라우팅 요청이 URI에 따라 라우터 클래스 객체가 있습니다.
3.web.xml - Intellij는 기본적으로 version = "3.1"인 web.xml을 만들고 에 아무것도 넣지 않고을 추가합니다. 그래서 나는이 전쟁을 폭발 넣었을 때 나는 구조
WEB-INF
--classes
-----| All compiled class files
--lib
-----| restlet jar files and json jar files (org.json.jar org.restlet.jar org.restlet.ext.json.jar org.restlet.ext.servlet.jar)
--web.xml
다음 한
나는 유물 구성을 완료하고 내 "전쟁이 폭발"에있다 (아래의 web.xml이 추가) 그 web.xml을 수정 내 아파치 바람둥이 webapps 폴더를 누른 다음 바람둥이 다시 시작 HTML/CSS/JS 파일에 액세스 할 수 있어요. 하지만 내 AJAX 호출은 항상 404 오류를 제공합니다. 나는 stackoverflow 및 다른 웹 사이트에서 모든 솔루션을 시도했지만 아무 도움도.
web.xml을
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<!-- Application class name -->
<context-param>
<param-name>org.restlet.application</param-name>
<param-value>
MyServer
</param-value>
</context-param>
<!-- Restlet adapter -->
<servlet>
<servlet-name>ServerServlet</servlet-name>
<servlet-class>
org.restlet.ext.servlet.ServerServlet
</servlet-class>
</servlet>
<!-- Catch all requests -->
<servlet-mapping>
<servlet-name>ServerServlet</servlet-name>
<url-pattern>/Projects/*</url-pattern>
</servlet-mapping>
</web-app>
MyServer의 클래스
Router classpublic class MyServer extends Application{
public static void main(String []args)
{
Component component = new Component();
component.getServers().add(Protocol.HTTP, 8080);
Application application = new MyServer();
// Attach the application to the component and start it
component.getDefaultHost().attach(application);
try {
component.start();
} catch (Exception e) {
e.printStackTrace();
}
}
//Method for attaching the URIs for web services
public synchronized Restlet createInboundRoot()
{
Router router = new Router(getContext());
//System.out.println("In router");
//Attaching URIsl
router.attach("/Projects/{projectID}/Enclosures/{enclID}/getStructure", StructureCalculations.class);
}
}
그리고 내 AJAX는 URI이
http://localhost:8080/Projects/p1/Enclosures/e1/getStructure?param1=x¶m2=y
처럼 보이는 전화