My JSPs do not resolve.
Below are my application properties
spring.application.name=codereaper
spring.datasource.url=jdbc:mysql://192.168.0.28:3306/reference_tables?allowPublicKeyRetrieval=true&useSSL=false&autoReconnect=true&
spring.datasource.username=reference
spring.datasource.password=Peconic4Bay
spring.datasource.pool-size=5
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
server.servlet.context-path=/codereaper
security.basic.enable=false
management.security.enabled=false
#mybatis
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration
mybatis.config-location=classpath:mybatis/MapperConfig.xml
mybatis.type-aliases-package=classpath:com.empirestateids.domain
mybatis.mapper-locations=classpath*:mybatis/*Mapper.xml
management.endpoints.web.exposure.include=mappings
server.error.whitelabel.enabled=false
I have tried using application properties to detail where my JSPs are as well as an internal view resolver
he JSPs in the war file are in the war file at /WEB-INF/jsp/*
Not sure why the views don’t resolve Eg I get a 404 on the /home view but the error page renders.
I have tried using a Internal view resolver as below since the application properties do not appear to be working
Here is my Controller
@Controller
public class MainController {
static Logger logger = LogManager.getLogger(MainController.class);
@Autowired
MainService mainService;
@RequestMapping("/home")
public String home(Model model,HttpServletRequest request,HttpServletResponse response) {
MainContent mainContent = new MainContent();
Device currentDevice = DeviceUtils.getCurrentDevice(request);
DevicePlatform platform = currentDevice.getDevicePlatform();
String username;
logger.error("Main Controller:/home"+ " Device Mobile:"+currentDevice.isMobile());
model.addAttribute("userName", "Username");
model.addAttribute(platform);
return("home");
}
@Configuration
@EnableWebMvc
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/jsp/");
resolver.setSuffix(".jsp");
registry.viewResolver(resolver);
}
}
Here is the Spring main
@SpringBootApplication(exclude = { SecurityAutoConfiguration.class })
@MapperScan("com.empirestateids.dao")
@MappedTypes({Address.class,Article.class,Contact.class,CvxAttributes.class,
CvxCatalogs.class,CvxCodes.class,Email.class,Events.class,GroupAuthority.class,
GroupMember.class,Groups.class,Icd10.class,Icd11.class,IdSeq.class,
IpowerliftId.class,Loinc.class,Lookup.class,PersistentLogins.class,
Person.class, Registration.class, RxNormCodes.class, Users.class})
public class CodereaperApplication {
static Logger logger = LogManager.getLogger(CodereaperApplication.class);
public static void main(String[] args) {
System.setProperty("server.servlet.context-path", "/codereaper");
SpringApplication.run(CodereaperApplication.class, args);
logger.debug("Debug");
logger.error("Error");
logger.info("Info");
}
@Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
return args -> {
logger.debug("Debug logging");
logger.error("Error logging");
logger.info("Info logging");
System.out.println("Let's inspect the beans provided by Spring Boot:");
String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
System.out.println(beanName);
}
};
}
}
charles didonato is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.