Web.xml
图书管理
<servlet>
<servlet-name>BooksManagement</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>BooksManagement</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/student.jsp</welcome-file>
</welcome-file-list>
我的控制器是 AddStudentController
@Controller
public class AddStudentController {
@RequestMapping(value = "/student", method = RequestMethod.GET)
public ModelAndView student() {
return new ModelAndView("student", "command", new Students());
}
@RequestMapping(value = "/addStudent", method = RequestMethod.POST)
public String addStudent(@ModelAttribute("SpringWeb") Students student,ModelMap model) {
model.addAttribute("firstName", student.getFirstName());
model.addAttribute("lastName", student.getLastName());
model.addAttribute("id", student.getId());
return "result";
}
}
原始服务器找不到目标资源的当前表示,或者不愿意透露存在的错误
答案 0 :(得分:1)
起初,我试图打 student.jsp 而没有打 index.jsp 。在index.jsp中输入<a href="student">Click here...</a>
之后。
还添加了
<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>
在web.xml中
现在解决了
由于Controller正在搜索 /学生,因此没有提及
@Controller
public class AddStudentController {
@RequestMapping(value = "/student", method = RequestMethod.GET)
public ModelAndView student() {
return new ModelAndView("student", "command", new Students());
}