ビルドプロセスの情報を持つ静的HTMLページにアクセスしようとしています。これはmaven warプラグインを使用して生成されます。しかし、プロジェクトのルートに生成されたbuild.html
にアクセスしようとすると、何も表示されず、アクセスできなくなります。ただし、src/main/webapp/static
の下にあるHTMLファイルにアクセスしようとすると、URL:http://localhost:8180/MyProject/static/about/build.html
を使用してアクセスできます。プロジェクトルートから静的build.htmlにアクセスできない
しかし、おそらく私が探しているこの方法でアクセスすることはできません:http://localhost:8180/MyProject/build.html
。
私MyProject.war内部構造
MyProject.war
META-IN
static
WEB-INF
build.html
Mavenの戦争のプラグイン
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp/static/about</directory>
<filtering>true</filtering>
</resource>
</webResources>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
WebConfigurationクラス(web.xmlファイル)
public class AppWebInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class[] { AppWebConfiguration.class };
}
@Override
protected Class<?>[] getServletConfigClasses() {
return null;
}
@Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
}
AppWebConfiguration(春コンフィギュレーション)
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "com.mypackages")
public class AppWebConfiguration extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/static/**").addResourceLocations("/static/");
}
@Bean
public ViewResolver viewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setViewClass(JstlView.class);
viewResolver.setPrefix("/WEB-INF/views/");
viewResolver.setSuffix(".jsp");
return viewResolver;
}
}
春のセキュリティ設定
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/login").anonymous()
.antMatchers("/", "/home").hasRole(ADMIN)
.antMatchers("/admin/**").hasRole(ADMIN)
.and().formLogin().loginPage("/login")
.usernameParameter("ssoId").passwordParameter("password")
.and().csrf()
.and().exceptionHandling().accessDeniedPage("/errorpage");
}
示唆してください。前もって感謝します!
web.xmlを表示してください。 – jlumietu
ありがとうございます。設定ファイルをいくつか追加しました。お勧めします。 – Sam