gpt4 book ai didi

java - 未找到页面 :1136 - No mapping found for HTTP request with URI [] in DispatcherServlet with name 'spring'

转载 作者:行者123 更新时间:2023-12-01 23:28:27 30 4
gpt4 key购买 nike

当我单击welcome.jsp 中的任何链接时,我收到警告 PageNotFound:1136 - 在 DispatcherServlet 中未找到名称为“spring”的 URI [/CATestSlotBooking/show] 的 HTTP 请求映射。

下面是 Controller 类

@Controller
public class BookingSlotController {

@RequestMapping(value = "/show", method = RequestMethod.GET)
public String showBookingPage(ModelMap model) {
BookingSlotVO bookingDetailsVO = new BookingSlotVO();
model.addAttribute("bookingSlotVO", bookingDetailsVO);
return "booking";
}

调度程序 servlet MXL

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">

<context:annotation-config />

<context:component-scan base-package="com.cts" />

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>

<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
<property name="defaultLocale" value="en" ></property>
</bean>

<mvc:interceptors>
<bean id="localChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang" />
</bean>
</mvc:interceptors>
</beans>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>OnlineTestSlotBooking</display-name>
<welcome-file-list>
<welcome-file>Welcome.html</welcome-file>
<welcome-file>Welcome.htm</welcome-file>
<welcome-file>Welcome.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

</web-app>

欢迎.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Welcome page</title>
</head>

<body>
<p> CA Enablement Assessments </p>
<hr>

<a href="show">Book a slot for assessment</a>

<div style="text-align: right; background-color: yellow ">
<a href="${pageContext.request.contextPath}/show?lang=en" >Login(English)
</a>
&nbsp;&nbsp;
<a href="${pageContext.request.contextPath}/show?lang=es" >Login(Spanish)
</a>

</div>
</body>
</html>

enter image description here

当我单击welcome.jsp 中的任何链接时,我收到404 错误。如果我在 web.xml 中将 URL 模式更改为/* 或 *.do,则不会获得welcome.jsp 页面。

最佳答案

删除<welcome-file-list>来自 web.xml。

更新后的web.xml :

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>OnlineTestSlotBooking</display-name>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

</web-app>

关于java - 未找到页面 :1136 - No mapping found for HTTP request with URI [] in DispatcherServlet with name 'spring' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58299445/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com