Skip to content

Instantly share code, notes, and snippets.

View CheolhoJeon's full-sized avatar
🙏

Cheolho Jeon CheolhoJeon

🙏
View GitHub Profile
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>spring.profiles.active</param-name>
<param-value>dev</param-value>
</init-param>
<init-param>
db.driver=org.postgresql.Driver
db.url=jdbc:postgresql://localhost:5432/spring5fs
db.user=charlie
db.password=charlie123
package config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.io.ClassPathResource;
@Configuration
public class PropertyConfig {
package config;
import org.apache.tomcat.jdbc.pool.DataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class DsConfigWithProp {
package spring;
import org.springframework.beans.factory.annotation.Value;
public class Info {
@Value("${info.version}")
private String version;
public String getVersion() {
package spring;
import org.springframework.beans.factory.annotation.Value;
public class Info {
private String version;
public String getVersion() {
return version;
@Configuration
@EnableWebMvcpublic class MvcConfig implements WebMvcConfigurer {
@Override
public void configureDefaultServletHandling(final DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
@Override
public void configureViewResolvers(final ViewResolverRegistry registry) {
@Configuration
@EnableWebMvcpublic
class MvcConfig implements WebMvcConfigurer {
...
@Override
public void configureViewResolvers(final ViewResolverRegistry registry) {
registry.jsp("/WEB-INF/view/", ".jsp");
}
// 위의 설정은 내부적으로 아래와 같은 설정으로 빈을 등록
@Bean
public ViewResolver viewResolver() {
InternalResourceViewResolver vr = new InternalResourceViewResolver();
vr.setPrefix("/WEB-INF/view");
vr.setSuffix(".jsp");
return vr;
}
@Controller
@RequestMapping("/register")
public class RegistController {
@RequestMapping("/step1")
public String handleStep1() {
...
}
@RequestMapping("/step2")