Я запускаю приложение для загрузки весны. Когда я ввожу URL http://localhost:8080
(или http://localhost:8080/index.jsp
) Я ожидаю, что файл index.jsp загрузится, но я получаю следующую ошибку в браузере.Как удалить страницу с ошибкой ярлыка в приложении весенней загрузки?
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Sat Mar 05 21:56:33 IST 2016
There was an unexpected error (type=Not Found, status=404).
No message available
Мой index.jsp присутствует в каталоге WebContent и мой класс AppConfig выглядит следующим образом
@EnableJpaRepositories("com.test.repository")
@Configuration
@EnableTransactionManagement
@ComponentScan(basePackages="com.test.domain")
@PropertySource(value={"classpath:application.properties"})
public class AppConfig {
@Autowired
private Environment environment;
@Bean
public DataSource dataSource() {
DriverManagerDataSource datasource = new DriverManagerDataSource();
datasource.setDriverClassName(environment.getRequiredProperty("spring.datasource.driver-class-name"));
datasource.setUrl(environment.getRequiredProperty("spring.datasource.url"));
datasource.setUsername(environment.getRequiredProperty("spring.datasource.username"));
datasource.setPassword(environment.getRequiredProperty("spring.datasource.password"));
return datasource;
}
@Bean
public ViewResolver getViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/jsp/");
resolver.setSuffix(".jsp");
return resolver;
}
@Bean
public WebMvcConfigurerAdapter forwarderToIndex() {
return new WebMvcConfigurerAdapter() {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("forward://index.jsp");
}
};
}
}
Я также упомянул this, которые не помогли мне. Как устранить эту ошибку и перенаправить на index.jsp?
, пожалуйста, напишите код для вашего контроллера –