Bị báo lỗi ko thể mapping trong java spring mvc

Lỗi cụ thể: WARNING: No mapping found for HTTP request with URI [/Tintuc/] in DispatcherServlet with name ‘TintucDispatcher’

wenb.xml

  <?xml version="1.0" encoding="UTF-8"?>
<web-app 
	id="WebApp_ID"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
	version="3.0">

	<servlet>
		<servlet-name>TintucDispatcher</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>/WEB-INF/TintucDispatcher-servlet.xml</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>

	
	<servlet-mapping>
		<servlet-name>TintucDispatcher</servlet-name>
		<url-pattern>/</url-pattern>
	</servlet-mapping>
</web-app>

TintucDispatcher-servlet.xml

<?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:cache="http://www.springframework.org/schema/cache"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:jee="http://www.springframework.org/schema/jee"
	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/cache http://www.springframework.org/schema/cache/spring-cache-4.3.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
		http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.3.xsd
		http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd">
		
		<context:component-scan base-package="tintuc.huannv.controller" />
		
		
		<mvc:resources location="/teamplates/" mapping="teamplates/**"/>
		<mvc:annotation-driven enable-matrix-variables="true"/>
		
		<import resource="classpath:IoC.xml"/>
	
		<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
			<property name="prefix" value="/views/"></property>
			<property name="suffix" value=".jsp"></property>
		</bean>
		</beans>

chạy báo lỗi ko thể mapping…
có ai giúp em với

Post class Controller lên đi bạn

package tintuc.huannv.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/")
public class ControllerViews {
public String Views() {

	return "index";
}

}

Bạn post cấu trúc project xem nào?

Bạn chưa mapping ‘/Tintuc’ trong Controller kìa
Edit: sorry nãy mình nhìn ko kĩ đọc thành topic

1 Like

là như thế nào vậy ạ??

Cụ thể là bạn chạy app lên nó báo thế hay truy cập url kiểu http://localhost:8080/App/Tintuc thì nó báo lỗi 404?

1 Like
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?