2016-11-11 51 views
0

我有一個簡單的彈簧啓動應用程序,每次DispatcherServlet處理一些我不知道它來自哪裏的東西。當我調用任何REST API時,它將在實際調用之前調用。爲什麼Spring啓動應用程序有一個默認映射器

這是調試中的消息。任何人都可以引導我,如果我錯過了基本知識。

DispatcherServlet with name 'dispatcherServlet' processing POST request for [/login] 

其實我有這個名字映射API,所以不知道這是如何被設置

這裏是我的控制,我稱之爲/ getUserInfo有沿的那一刻,/登錄也被稱爲。我的整個控制器用@RestController註釋。

@RequestMapping(value = "/login", method = RequestMethod.POST) 
public List<User> login(@RequestParam(value = "userID") String userID,@RequestParam(value = "userPassword") String userPassword) { 
    return service.checkUser(userEmail, userPassword, repository); 
} 

@RequestMapping(value = "/getUserInfo", method = RequestMethod.GET) 
public User getUserInfo(@RequestParam("userID") String userID, User user) { 
    return service.getuserDetail(userID, user, repository); 
} 

此外,訂單是基於觸發器的隨機。下面是完整的堆棧跟蹤

2016-11-12 09:16:48.963 DEBUG 9848 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet  : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/getUserInfo] 
2016-11-12 09:16:48.963 DEBUG 9848 --- [nio-8080-exec-2] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /getUserInfo 
2016-11-12 09:16:48.965 DEBUG 9848 --- [nio-8080-exec-2] s.w.s.m.m.a.RequestMappingHandlerMapping : Returning handler method [public com.boot.model.User com.boot.controller.ConsumerController.getUserInfo(java.lang.String,com.boot.model.User)] 
2016-11-12 09:16:48.966 DEBUG 9848 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet  : Last-Modified value for [/getUserInfo] is: -1 
2016-11-12 09:16:48.968 DEBUG 9848 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet  : DispatcherServlet with name 'dispatcherServlet' processing POST request for [/login] 
2016-11-12 09:16:48.971 DEBUG 9848 --- [nio-8080-exec-3] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /login 
2016-11-12 09:16:48.973 DEBUG 9848 --- [nio-8080-exec-3] s.w.s.m.m.a.RequestMappingHandlerMapping : Returning handler method [public java.util.ArrayList<com.boot.model.User> com.boot.controller.ConsumerController.login(java.lang.String,java.lang.String)] 
2016-11-12 09:16:49.074 DEBUG 9848 --- [nio-8080-exec-3] o.s.web.cors.DefaultCorsProcessor  : Skip CORS processing: request is from same origin 

這裏是我的pom.xml

<dependencies> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>3.8.1</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-web</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>mysql</groupId> 
     <artifactId>mysql-connector-java</artifactId> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-data-jpa</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>com.h2database</groupId> 
     <artifactId>h2</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-data-mongodb</artifactId> 
    </dependency> 
    <!--<dependency> 
     <groupId>org.webjars</groupId> 
     <artifactId>angularjs</artifactId> 
     <version>1.4.9</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-thymeleaf</artifactId> 
    </dependency> 

    <dependency> <groupId>org.scala-lang</groupId> <artifactId>scala-library</artifactId> 
     <version>2.11.0</version> </dependency> <dependency> <groupId>org.scala-lang</groupId> 
     <artifactId>scala-library</artifactId> <version>2.11.0</version> </dependency> --> 
    <dependency> 
     <groupId>org.codehaus.jackson</groupId> 
     <artifactId>jackson-mapper-asl</artifactId> 
     <version>1.9.7</version> 
    </dependency> 
    <dependency> 
     <groupId>org.json</groupId> 
     <artifactId>json</artifactId> 
     <version>20160810</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-tomcat</artifactId> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>javax.websocket</groupId> 
     <artifactId>javax.websocket-api</artifactId> 
     <version>1.1</version> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-configuration-processor</artifactId> 
     <optional>true</optional> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-data-mongodb</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.mongodb</groupId> 
     <artifactId>mongo-java-driver</artifactId> 
     <version>3.0.4</version> 
    </dependency> 

</dependencies> 
+0

你可以顯示你的控制器代碼?你在類路徑上有Spring Security嗎? –

+0

@BrianClozel我已經添加了控制器代碼到我的初始後 – CrazyMac

+0

哪裏是你/ getUserInfo方法......你貼登錄方法2次 –

回答

0

有同春映射器沒有問題。這與我的HTML有關,這些按鈕被封裝在窗體標籤中,並且具有登錄操作。我錯過了這個不知何故,並在看大圖。感謝您的所有輸入

相關問題