The origin server did not find a current representation for the target resource or is not willing to disclose that one exists

created at 02-23-2022 views: 84

code

package com.chey.controller;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
  * @Author chey
  * @Date 2021-10-29 10:44
  * @Describe
  */
public class controllerMVCDemo implements Controller {
     @Override
     public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {

         ModelAndView modelAndView = new ModelAndView();
         //The encapsulated object is placed in modelandview
         modelAndView.addObject("msg","mvc-controller");
         //Encapsulate the jump view and put it in the modelandview
         modelAndView.setViewName("test");// /WEB-INF/ test.jsp
         return modelAndView;
     }
}

The reason is that the implemented controller interface is

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

And using javax in tomcat10 does not fit

solution

Just change to tomcat9

In fact, tomcat10 is only suitable for jakarta, but jakarta can be used in tomcat9

created at:02-23-2022
edited at: 02-23-2022: