Java休息服务和Web应用程序未在同一项目上运行

时间:2016-07-21 05:53:42

标签: java tomcat jersey java-api

我有一个Java动态Web项目,在这个项目中,我有休息服务和Web应用程序。

我的网络应用程序所有数据都在" WebContent"文件夹中。

我的index.html页面位于" WebContent"文件夹中。

我的web.xml代码在

下面
#pragma mark - Touch Events For Rotation of GRAPH

- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
UITouch* touch = [touches anyObject];
CGPoint touchPoint = [touch locationInView:self.view];

    prevAngle = [Utilities angleBetweenPoint:touchPoint toPoint:self.view.center];
/// convert negative angle into positive angle
    if(prevAngle < 0){
        prevAngle = PI_DOUBLE + prevAngle;
    }

    //
    [_viewStaticRadialPart hideToolTip];
}
- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
{
    CGFloat diffAngle, tempCurAngle, tempPrevAngle, curTransformAngle, newTransformAngle;

    NSLog(@"touchesMoved");
// Get the only touch (multipleTouchEnabled is NO)
    UITouch* touch = [touches anyObject];
    // Track the touch
    CGPoint touchPoint = [touch locationInView:self.view];


    curAngle = [Utilities angleBetweenPoint:touchPoint toPoint:self.view.center];

    /// convert negative angle into positive angle
    if(curAngle < 0){
        curAngle = PI_DOUBLE + curAngle;
    }
        prevAngle = curAngle;
}

-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self resetViewsOnceRotationStops];


}
- (void)touchesCancelled:(nullable NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event
{
    [resetViewsAfterTouchStops invalidate];
    resetViewsAfterTouchStops = nil;
}

我的服务代码

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>TestingMerge</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>TestingMerge</servlet-name>
    <servlet-class>com.sun.jersey.server.impl.container.servlet.ServletAdaptor</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>TestingMerge</servlet-name>
    <url-pattern>/*</url-pattern>
  </servlet-mapping>
</web-app>

目前,当我运行此项目时,在我的浏览器上点击package TestingMerge.aitc.io; import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.core.Response; import org.json.JSONObject; @Path("/TM") public class TestingMerge_Service { @POST @Consumes("application/x-www-form-urlencoded") @Path("/Register") public Response Register(String json) { JSONObject returnJson = new JSONObject(); try { JSONObject innerJsonObj = new JSONObject(json); User_Objects userObj = new User_Objects(); String email = innerJsonObj.getString("email"); String phone = innerJsonObj.getString("phone"); JSONObject jsonData = new JSONObject(); returnJson.put("success", true); returnJson.put("data", jsonData); } catch (Exception e) { JSONObject errorJson = new JSONObject(); errorJson.put("success", false); return Response.ok(errorJson.toString()).header("Access-Control-Allow-Origin", "*").build(); } return Response.ok(returnJson.toString()).header("Access-Control-Allow-Origin", "*").build(); } } 网址,它会显示空白页面。 但我可以使用以下网址

运行我的休息服务
http://localhost:8080/TestingMerge/

如果我从web.xml中删除了以下代码

http://localhost:8080/TestingMerge/TM/Register

然后运行此项目,然后在我的浏览器上点击<servlet> <servlet-name>TestingMerge</servlet-name> <servlet-class>com.sun.jersey.server.impl.container.servlet.ServletAdaptor</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>TestingMerge</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> URL我的应用程序成功运行。 但我的休息服务不使用http://localhost:8080/TestingMerge/网址拨打电话。

我正在使用Java和Tomcat 8。

0 个答案:

没有答案