如何将我的 css 和资源文件的 src 路径放在 netbeans web 应用程序中

how to put the src path of my css and resources files in a netbeans web application

你好,我正在开发一个 netbeans maven web 应用程序,我正在使用 spring mvc,我的 css 和资源文件有问题,当我加载页面时,它们没有显示在我的页面中它显示 404 未找到,我正在使用 java class 配置并且这里没有 xmls 是我的 java class soring mvc 配置

我的 MvcConfig class

@Configuration
@ComponentScan("controller")
@EnableWebMvc  
public class MvcConfig extends WebMvcConfigurerAdapter {  


    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
       registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
    }

    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
       configurer.enable();
    }

//  JSP VIEW-RESOLVER
    @Bean
    public InternalResourceViewResolver jspViewResolver() {
       InternalResourceViewResolver bean = new InternalResourceViewResolver();
       bean.setOrder(0);
       bean.setPrefix("/WEB-INF/html/");
       bean.setSuffix(".html");
       return bean;
    }

}

我的根配置class

@Configuration
@ComponentScan(basePackages = {"controller"})
@Import({MvcConfig.class})
public class RootConfig {

}

我的初始化器class

public class InitrMvc implements WebApplicationInitializer{

    @Override
    public void onStartup(ServletContext container) throws ServletException {        

        // Create the 'root' Spring application context
        AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
        rootContext.register(RootConfign.class);

        // Manage the lifecycle of the root application context
        container.addListener(new ContextLoaderListener(rootContext));

        // Create the dispatcher servlet's Spring application context
        AnnotationConfigWebApplicationContext dispatcherServlet = new AnnotationConfigWebApplicationContext();
        dispatcherServlet.register(MvcConfig.class);

        // Register and map the dispatcher servlet
        ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", new DispatcherServlet(dispatcherServlet));
        dispatcher.setLoadOnStartup(0);
        dispatcher.addMapping("/");
    }
}

和我的控制器class

@控制器 public class IncidenciaControlador {

@RequestMapping(value = "login/testPage", method = RequestMethod.GET)
   public String login(Model model) {



       return "login/testPage";
   }

}

和我的项目树结构

MyProjectMavenWeb
  --Web Pages
      --WEB-INF
          --htmlPages
              --login
                 --testPage.html
          --resources (at the same level as htmlPages)
             --img
                logo.png

和我的testPage.html

<div id="logo-group">
    <span id="logo"> <img src="../resources/img/logo.png"> </span>
</div>

++编辑:我正在尝试这条路../resources/img/logo.png

编辑

我尝试使用海报建议的这种树结构的解决方案并且有效

MyProjectMavenWeb

--网页 --resources(与 htmlPages 处于同一级别) --img logo.png --WEB-INF --html页面 - 登录 --testPage.html

MyProjectMavenWeb
  --Web Pages
    --resources (at the same level as htmlPages)
      --img
        logo.png
    --WEB-INF
        --htmlPages
            --login
               --testPage.html

试试这个结构