'using requestmapping annotation to request page
I am using eclipse to write some spring MVC project, but my project can't find the variable of requestmapping I gave. so I write some test controller to display my test.jsp
controller.java
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping("/")
public class test{
@RequestMapping(value="test",method={RequestMethod.GET})
public String test() {
return "test";
}
}
test.jsp
<%@ page language="java" contentType="text/html; charset=BIG5"
pageEncoding="BIG5"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="BIG5">
<title>Insert title here</title>
</head>
<body>
<h6>hello world!</h6>
</body>
</html>
Sadly,no matter how I've tried,my tomcat server just can't find the page by using the path
http://localhost:(port)/(projectname)/test
Eclipse version also confused me.I used to put my jsp beneath the webcontent/web-inf in old version of eclipse.However,after updating my eclipse to 2021-06 ,I'm not surely understand where should I put my jsp to enable my controller can get use of it.

I've found if I just put my jsp under my webapp folder,I could use absolute path to get my jsp
http://localhost:8080/acqdemo/test.jsp
However, It might no longer be as Spring MVC Framework anymore.Sorry to ask this simple question. I'm a newbie of java spring, and I just hope anyone can help me solve this problem.
btw this is my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
<display-name>acqdemo</display-name>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<absolute-ordering />
</web-app>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
