Angular JS POST返回404(Not Found)但在Postman中有效

时间:2014-12-31 15:09:49

标签: angularjs rest spring-mvc tomcat7 cors

我正在尝试使用Angular JS将请求发布到在tomcat上运行的其他应用程序。 我收到错误No' Access-Control-Allow-Origin',所以我在该应用程序中添加了CORS过滤器,错误消失了。现在我收到404(Not Found)错误。但该帖子正在邮递员(铬扩展)

As per this Link Postman拥有跨域访问权限,因为它是Chrome应用。虽然Angular JS没有。所以即使在启用CORS之后,为什么我无法发帖。

很多问题谈论这个问题,但我找不到明确的解决方案。因此我发布了这个问题

邮差要求(工作)

POST http://10.126.130.71:8081/helpdesk/WebObjects/Helpdesk.woa/ra/Tickets?username=admin&apiKey=kzJWg4CmUq8BT8jNXFeXGif1duPbr6QA5jXt4w7F HTTP/1.1
Host: 10.126.130.71:8081
Connection: keep-alive
Content-Length: 412
Cache-Control: no-cache
Origin: chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop
Content-Type: application/json
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36
Postman-Token: 473cb169-6ba5-bdfc-fe7f-dc170cacbe8a
Accept: */*
DNT: 1
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8

回复 - 工作

HTTP/1.1 201 Created
Server: Apache-Coyote/1.1
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop
Vary: Origin
x-webobjects-loadaverage: 2
x-webobjects-servlet: YES
Content-Type: application/json
Content-Length: 116
Date: Wed, 31 Dec 2014 14:58:46 GMT

{"id":94,"type":"Ticket","lastUpdated":"2014-12-31T20:28:46Z","locationId":null,"statusTypeId":1,"subject":"treyy"}

Angular JS POST - 无效

OPTIONS http://10.126.130.71:8081/helpdesk/WebObjects/Helpdesk.woa/ra/Tickets?username=admin&apiKey=kzJWg4CmUq8BT8jNXFeXGif1duPbr6QA5jXt4w7F HTTP/1.1
Host: 10.126.130.71:8081
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Access-Control-Request-Method: POST
Origin: http://10.126.169.11:8010
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36
Access-Control-Request-Headers: accept, content-type
Accept: */*
DNT: 1
Referer: http://10.126.169.11:8010/fms/app.html
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8

响应

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Access-Control-Allow-Origin: http://10.126.169.11:8010
Access-Control-Allow-Credentials: true
Vary: Origin
Access-Control-Allow-Methods: POST, GET, OPTIONS, HEAD
Access-Control-Allow-Headers: accept, content-type
Content-Length: 0
Date: Wed, 31 Dec 2014 15:00:27 GMT



POST http://10.126.130.71:8081/helpdesk/WebObjects/Helpdesk.woa/ra/Tickets?username=admin&apiKey=kzJWg4CmUq8BT8jNXFeXGif1duPbr6QA5jXt4w7F HTTP/1.1
Host: 10.126.130.71:8081
Connection: keep-alive
Content-Length: 416
Pragma: no-cache
Cache-Control: no-cache
Accept: application/json, text/plain, */*
Origin: http://10.126.169.11:8010
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36
Content-Type: application/json;charset=UTF-8
DNT: 1
Referer: http://10.126.169.11:8010/fms/app.html
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8

响应 - 错误

HTTP/1.1 404 Not Found
Server: Apache-Coyote/1.1
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://10.126.169.11:8010
Vary: Origin
x-webobjects-loadaverage: 2
x-webobjects-servlet: YES
Content-Type: application/json
Content-Length: 4561
Date: Wed, 31 Dec 2014 15:00:27 GMT

{"stackTrace":"java.lang.reflect.InvocationTargetException\r\n\tat com.webobjects.appserver._private.WOActionRequestHandler._handleRequest(WOActionRequestHandler.java:269)\r\n\tat com.webobjects.appserver._private.WOActionRequestHandler.handleRequest(WOActionRequestHandler.java:161)\r\n\tat com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java:1687)\r\n\tat er.extensions.appserver.ERXApplication.dispatchRequestImmediately(ERXApplication.java:2029)\r\n\tat er.extensions.appserver.ERXApplication.dispatchRequest(ERXApplication.java:1994)\r\n\tat com.macsdesign.util.MDSApplication.dispatchRequest(MDSApplication.java:475)\r\n\tat com.macsdesign.whd.ui.Application.dispatchRequest(Application.java:285)\r\n\tat com.webobjects.jspservlet._WOApplicationWrapper.servletDispatchRequest(_WOApplicationWrapper.java:131)\r\n\tat com.webobjects.jspservlet.WOServletAdaptor._handleRequest(WOServletAdaptor.java:727)\r\n\tat com.webobjects.jspservlet.WOServletAdaptor.doPost(WOServletAdaptor.java:695)\r\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:647)\r\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:728)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)\r\n\tat com.macsdesign.util.SessionCookieOverwriterFilter.doFilter(Unknown Source)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)\r\n\tat com.macsdesign.filters.JsessionIdStripperFilter.doFilter(Unknown Source)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)\r\n\tat com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:163)\r\n\tat com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:237)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)\r\n\tat org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)\r\n\tat org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)\r\n\tat org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)\r\n\tat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)\r\n\tat org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)\r\n\tat org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)\r\n\tat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)\r\n\tat org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)\r\n\tat org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)\r\n\tat org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)\r\n\tat java.lang.Thread.run(Unknown Source)\r\nCaused by: java.lang.NullPointerException\r\n\tat er.rest.ERXRestRequestNode.toString(ERXRestRequestNode.java:1077)\r\n\tat er.rest.format.ERXRestFormat.toString(ERXRestFormat.java:226)\r\n\tat com.macsdesign.whd.rest.controllers.RouteControllerBase.errorResponse(RouteControllerBase.java:418)\r\n\tat er.rest.routes.ERXRouteController.performActionNamedWithError(ERXRouteController.java:1598)\r\n\tat er.rest.routes.ERXRouteController.performActionNamed(ERXRouteController.java:1411)\r\n\tat com.macsdesign.whd.rest.controllers.RouteControllerBase.performActionNamed(RouteControllerBase.java:357)\r\n\tat er.rest.routes.ERXRouteController.performActionNamed(ERXRouteController.java:1340)\r\n\tat com.macsdesign.whd.rest.controllers.RouteControllerBase.performActionNamed(RouteControllerBase.java:440)\r\n\tat com.webobjects.appserver._private.WOActionRequestHandler._handleRequest(WOActionRequestHandler.java:259)\r\n\t... 36 more\r\n","errorMessage":"An error occurred while handling request /helpdesk/WebObjects/Helpdesk.woa/ra/Tickets?username\u003dadmin\u0026apiKey\u003dkzJWg4CmUq8BT8jNXFeXGif1duPbr6QA5jXt4w7F: java.lang.NullPointerException"}

我还尝试将请求发布到我的spring应用程序并使用RestTemplate我尝试将其从我的服务器发布到目标服务器。我仍然得到错误404。

0 个答案:

没有答案