在命名url时出错,filenotfoundexception说

时间:2015-01-19 15:18:27

标签: java javascript angularjs

我试图通过js文件调用控制器,但收到以下错误:

[ERROR   ] SRVE0777E: Exception thrown by application class 'com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.service:1,604'
javax.servlet.ServletException: java.io.FileNotFoundException: SRVE0190E: File not found: /rest/user/details
    at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.service(DefaultExtensionProcessor.java:1604)
    at [internal classes]
    at org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler.handleRequest(DefaultServletHttpRequestHandler.java:122)
    at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:51)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:575)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1274)
    at [internal classes]
Caused by: java.io.FileNotFoundException: SRVE0190E: File not found: /rest/user/details
    at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:528)
    ... 12 more

[ERROR   ] SRVE0777E: Exception thrown by application class 'com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.service:1,604'
javax.servlet.ServletException: java.io.FileNotFoundException: SRVE0190E: File not found: /rest/user/details
    at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.service(DefaultExtensionProcessor.java:1604)
    at [internal classes]
    at org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler.handleRequest(DefaultServletHttpRequestHandler.java:122)
    at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:51)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:575)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1274)
    at [internal classes]
Caused by: java.io.FileNotFoundException: SRVE0190E: File not found: /rest/user/details
    at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:528)
    ... 12 more

[WARNING ] SRVE0190E: File not found: /rest/user/details
[ERROR   ] SRVE0777E: Exception thrown by application class 'com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.service:1,604'
javax.servlet.ServletException: java.io.FileNotFoundException: SRVE0190E: File not found: /rest/user/details
    at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.service(DefaultExtensionProcessor.java:1604)
    at [internal classes]
    at org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler.handleRequest(DefaultServletHttpRequestHandler.java:122)
    at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:51)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:575)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1274)
    at [internal classes]
Caused by: java.io.FileNotFoundException: SRVE0190E: File not found: /rest/user/details
    at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:528)
    ... 12 more

[ERROR   ] SRVE0777E: Exception thrown by application class 'com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.service:1,604'
javax.servlet.ServletException: java.io.FileNotFoundException: SRVE0190E: File not found: /rest/user/details
    at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.service(DefaultExtensionProcessor.java:1604)
    at [internal classes]
    at org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler.handleRequest(DefaultServletHttpRequestHandler.java:122)
    at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:51)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:575)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1274)
    at [internal classes]
Caused by: java.io.FileNotFoundException: SRVE0190E: File not found: /rest/user/details
    at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:528)

js文件如下:

 'use strict';
    (function () {           
        var user=angular.module('sol.user', []);
    user.controller('sol.user.UserController', UserController);
    UserController.$inject=['$scope','$rootScope','$http','$state'];
       function UserController($scope, $rootScope, $http,$state){
           $rootScope.userInformation  ={};
           $http({method: 'GET',
                url: 'rest/user/details'})
                .success(function(data) {
                    $rootScope.userInformation = data;
                   $state.go('home.search');
                                    })
                .error(function(data) {
                      $scope.profiles = data;
                $state.go('home.userError');                   
                });        }          
    })();

,Java控制器的映射如下:

@Controller
@RequestMapping("/user")
public class UserController {       
    private static final Logger LOGGER = LoggerFactory
            .getLogger(UserController.class);
    private static final String SAML_HEADER = "esi2token";    
    @RequestMapping(method = RequestMethod.GET, value = "/details", produces="application/json")
    public @ResponseBody String
    getUserDetails(HttpServletRequest request) {

web.xml也包含:

<servlet>
    <servlet-name>application-servlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/resources/applicationContext.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>application-servlet</servlet-name>
    <url-pattern>/rest/*</url-pattern>
  </servlet-mapping>
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/resources/applicationContext.xml</param-value>
  </context-param>

请告诉我哪里出错了

1 个答案:

答案 0 :(得分:0)

url参数不完整,看起来应该像

url: 'http://httpbin.org/rest/user/details'