** 我已经尝试解决这个问题超过几个小时,但我不能,“我在 java spring boot 中有一个简单的 mvc 应用程序,当我运行该程序时它说出现以下错误”那么要获得的步骤是什么摆脱这种按摩,我尝试通过在 application.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
我的 Controller 在这里
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);
}
}
最佳答案
将@ResponseBody 注释放在 ShowRegistration(-) 方法的顶部,它应该可以工作。
关于java - 退出 "ERROR"调度,状态 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60482354/