0

我在spring mvc上写了一些东西,我在配置文件中得到了这个

 @RequestMapping(value={"/userPage"},method = RequestMethod.GET)
    public String userPageController (Model model, Principal principal) {
        username = principal.getName();
        Set<Mesurements> mesurements = java.util.Collections.EMPTY_SET;
        mesurements =  measurementsDAO.findUserMesur(username);

        model.addAttribute("user", username);
        model.addAttribute("mesurements", mesurements);
        return "userPage";      
  } 

   @RequestMapping(value={"/userPage/addProject"}, method = RequestMethod.GET)
        public String addProjectController (Model model, Principal principal) {
        model.addAttribute("user", username);
        return "addProject";      
  }    `

因此,当我移至 8084/Grad/userPage.htm 时,所有内容(css、图像)都会出现,但是当我移至 8084/Grad/userPage/addProject.htm 时,css 或图像中不会出现任何内容

任何人都可以帮忙吗?然后

4

1 回答 1

0

您需要添加注册表资源处理程序,如下所示

/**
 * @param registry Resource handler registry
 * @see WebMvcConfigurationSupport#addResourceHandlers(ResourceHandlerRegistry)
 */
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
    logger.info("Adding resources handlers");
    final String[] RESOURCES = { "/resources/**" };

    registry.addResourceHandler(RESOURCES).addResourceLocations(RESOURCES).setCachePeriod(86400);
}
于 2013-10-01T20:04:54.383 回答