我已经一步一步地遵循了一切,但是当我启动我的控制器时,我得到了这个错误
`The requested resource is not available.`
控制器代码:
@Controller
public class HomeController {
@Autowired
private IMusicStoreService musicStoreService;
@RequestMapping(value="/")
public ModelAndView test(HttpServletResponse response) throws IOException{
return new ModelAndView("home","musicDetForm",new MusicDetails());
}
@RequestMapping(value="AddSong",method = RequestMethod.POST)
@ResponseBody
public String addSong(@ModelAttribute("musicDetForm") MusicDetails musicDetails){
return musicStoreService.addSong(musicDetails);
}
@RequestMapping(value = "SongList/",method = RequestMethod.GET)
@ResponseBody
public List<MusicDetails> getSongList(){
return musicStoreService.getSongList();
}
}
这是控制器代码的github网址 https://github.com/AishwaryaThangavelu/Spring-Repository/blob/master/MusicStore/src/main/java/aish/vaishno/musicstore/controller/HomeController.java
这是我的web.xml代码
<context-param>
<param-name>contextClass</param-name>
<param-value>
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>SpringDispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextClass</param-name>
<param-value>
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
</param-value>
</init-param>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>aish.vaishno.musicstore</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>SpringDispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
假设一切都没问题,请问我出错了什么。