java正在退出“错误”调度,状态404
**我已经尝试解决这个问题超过几个小时了,但我无法“我在java spring boot中有一个简单的mvc应用程序,当我运行程序时,它会显示以下错误”那么,消除这个问题的步骤是什么,我尝试在应用程序中添加组件扫描。java,但它不起作用**
2020-03-02 10:19:17.510 INFO 16708 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 3 ms
2020-03-02 10:19:17.516 DEBUG 16708 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : GET "/Registration", parameters={}
2020-03-02 10:19:17.519 DEBUG 16708 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to com.rohit.flightreservation.controller.UserController#ShowRegistration()
2020-03-02 10:19:17.533 DEBUG 16708 --- [nio-8080-exec-1] o.s.w.s.v.ContentNegotiatingViewResolver : Selected 'text/html' given [text/html, application/xhtml+xml, image/webp, image/apng, application/xml;q=0.9, application/signed-exchange;v=b3;q=0.9, */*;q=0.8]
2020-03-02 10:19:17.533 DEBUG 16708 --- [nio-8080-exec-1] o.s.w.servlet.view.InternalResourceView : View name 'login/registration', model {}
2020-03-02 10:19:17.534 DEBUG 16708 --- [nio-8080-exec-1] o.s.w.servlet.view.InternalResourceView : Forwarding to [login/registration]
2020-03-02 10:19:17.536 DEBUG 16708 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : "FORWARD" dispatch for GET "/login/registration", parameters={}
2020-03-02 10:19:17.538 DEBUG 16708 --- [nio-8080-exec-1] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped to ResourceHttpRequestHandler ["classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/", "/"]
2020-03-02 10:19:17.539 DEBUG 16708 --- [nio-8080-exec-1] o.s.w.s.r.ResourceHttpRequestHandler : Resource not found
2020-03-02 10:19:17.539 DEBUG 16708 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Exiting from "FORWARD" dispatch, status 404
2020-03-02 10:19:17.540 DEBUG 16708 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed 404 NOT_FOUND
2020-03-02 10:19:17.540 DEBUG 16708 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : "ERROR" dispatch for GET "/error", parameters={}
2020-03-02 10:19:17.540 DEBUG 16708 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#errorHtml(HttpServletRequest, HttpServletResponse)
2020-03-02 10:19:17.545 DEBUG 16708 --- [nio-8080-exec-1] o.s.w.s.v.ContentNegotiatingViewResolver : Selected 'text/html' given [text/html, text/html;q=0.8]
2020-03-02 10:19:17.549 DEBUG 16708 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Exiting from "ERROR" dispatch, status 404
2020-03-02 10:19:18.319 DEBUG 16708 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : GET "/Registration", parameters={}
2020-03-02 10:19:18.319 DEBUG 16708 --- [nio-8080-exec-2] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to com.rohit.flightreservation.controller.UserController#ShowRegistration()
2020-03-02 10:19:18.320 DEBUG 16708 --- [nio-8080-exec-2] o.s.w.s.v.ContentNegotiatingViewResolver : Selected 'text/html' given [text/html, application/xhtml+xml, image/webp, image/apng, application/xml;q=0.9, application/signed-exchange;v=b3;q=0.9, */*;q=0.8]
2020-03-02 10:19:18.320 DEBUG 16708 --- [nio-8080-exec-2] o.s.w.servlet.view.InternalResourceView : View name 'login/registration', model {}
2020-03-02 10:19:18.320 DEBUG 16708 --- [nio-8080-exec-2] o.s.w.servlet.view.InternalResourceView : Forwarding to [login/registration]
2020-03-02 10:19:18.320 DEBUG 16708 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : "FORWARD" dispatch for GET "/login/registration", parameters={}
2020-03-02 10:19:18.320 DEBUG 16708 --- [nio-8080-exec-2] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped to ResourceHttpRequestHandler ["classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/", "/"]
2020-03-02 10:19:18.321 DEBUG 16708 --- [nio-8080-exec-2] o.s.w.s.r.ResourceHttpRequestHandler : Resource not found
2020-03-02 10:19:18.321 DEBUG 16708 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Exiting from "FORWARD" dispatch, status 404
2020-03-02 10:19:18.321 DEBUG 16708 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Completed 404 NOT_FOUND
2020-03-02 10:19:18.321 DEBUG 16708 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : "ERROR" dispatch for GET "/error", parameters={}
2020-03-02 10:19:18.322 DEBUG 16708 --- [nio-8080-exec-2] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#errorHtml(HttpServletRequest, HttpServletResponse)
2020-03-02 10:19:18.323 DEBUG 16708 --- [nio-8080-exec-2] o.s.w.s.v.ContentNegotiatingViewResolver : Selected 'text/html' given [text/html, text/html;q=0.8]
2020-03-02 10:19:18.323 DEBUG 16708 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Exiting from "ERROR" dispatch, status 404
2020-03-02 10:19:18.499 DEBUG 16708 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : GET "/Registration", parameters={}
2020-03-02 10:19:18.500 DEBUG 16708 --- [nio-8080-exec-4] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to com.rohit.flightreservation.controller.UserController#ShowRegistration()
2020-03-02 10:19:18.501 DEBUG 16708 --- [nio-8080-exec-4] o.s.w.s.v.ContentNegotiatingViewResolver : Selected 'text/html' given [text/html, application/xhtml+xml, image/webp, image/apng, application/xml;q=0.9, application/signed-exchange;v=b3;q=0.9, */*;q=0.8]
2020-03-02 10:19:18.501 DEBUG 16708 --- [nio-8080-exec-4] o.s.w.servlet.view.InternalResourceView : View name 'login/registration', model {}
2020-03-02 10:19:18.501 DEBUG 16708 --- [nio-8080-exec-4] o.s.w.servlet.view.InternalResourceView : Forwarding to [login/registration]
2020-03-02 10:19:18.501 DEBUG 16708 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : "FORWARD" dispatch for GET "/login/registration", parameters={}
2020-03-02 10:19:18.502 DEBUG 16708 --- [nio-8080-exec-4] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped to ResourceHttpRequestHandler ["classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/", "/"]
2020-03-02 10:19:18.503 DEBUG 16708 --- [nio-8080-exec-4] o.s.w.s.r.ResourceHttpRequestHandler : Resource not found
2020-03-02 10:19:18.503 DEBUG 16708 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Exiting from "FORWARD" dispatch, status 404
2020-03-02 10:19:18.503 DEBUG 16708 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Completed 404 NOT_FOUND
2020-03-02 10:19:18.503 DEBUG 16708 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : "ERROR" dispatch for GET "/error", parameters={}
2020-03-02 10:19:18.504 DEBUG 16708 --- [nio-8080-exec-4] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#errorHtml(HttpServletRequest, HttpServletResponse)
2020-03-02 10:19:18.505 DEBUG 16708 --- [nio-8080-exec-4] o.s.w.s.v.ContentNegotiatingViewResolver : Selected 'text/html' given [text/html, text/html;q=0.8]
2020-03-02 10:19:18.505 DEBUG 16708 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Exiting from "ERROR" dispatch, status 404
我的控制器在这里
package com.rohit.flightreservation.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class UserController {
@RequestMapping ("/Registration")
public ModelAndView ShowRegistration() {
ModelAndView modelAndView=new ModelAndView();
modelAndView.setViewName("login/registration");
return modelAndView;
}
}
这是我的申请
package com.rohit.flightreservation;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class FlightreservationApplication {
public static void main(String[] args) {
SpringApplication.run(FlightreservationApplication.class, args);
}
}
# 1 楼答案
将@ResponseBody注释放在ShowRegistration(-)方法的顶部,它应该可以工作