2017-01-09 11 views
0

を見つけていない私はこのようなWEB-INFフォルダがあります。 enter image description here春リソースの取り扱い:

をそして、私のwebconfig.javaに:私の見解で

@Bean 
public InternalResourceViewResolver internalResourceViewResolver() { 

    InternalResourceViewResolver resolver = new InternalResourceViewResolver(); 
    resolver.setPrefix("/WEB-INF/views/"); 
    resolver.setSuffix(".html"); 

    return resolver; 
} 



@Override 
public void addResourceHandlers(ResourceHandlerRegistry registry) { 

    registry.addResourceHandler("/resources/**") 
    .addResourceLocations("/WEB-INF/resources/"); 

} 

i」はこのようなリソースを呼び出すことができます[index.html ']:

<link rel="stylesheet" href="${pageContext.request.contextPath}/resources/lib/angular-toastr.css" > 

が、その後、リソースがロードされ、私は私のコントローラと私のインデックスページにアクセスしていFailed to load resource: the server responded with a status of 404 (Not Found)

を取得されていません。

@RequestMapping("/myShellPage") 
public String ShellPage() { 

    return "index"; 
} 

インデックスページがあるURL: http://localhost:8080/gestionprojet/transtu/myShellPage?#/

およびエラーを生成するリソースは、http://localhost:8080/gestionprojet/transtu/$%7BpageContext.request.contextPath%7D/resources/lib/angular-toastr.css

です。私は、問題は、私はそれをやっている、 `$ {pageContext.request.contextPath}`原因から来ていると思います

+0

を動作するはずこれを試していただき、ありがとうございますjspファイルの代わりにhtmlファイルに保存します。これに対する代替案はありますか? –

答えて

0

はそれが

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

静的リソースに

<link href="<c:url value="/resources/lib/angular-toastr.css" />" rel="stylesheet">