commit
fda88fd83e
|
@ -20,10 +20,6 @@
|
||||||
<artifactId>spring-oxm</artifactId>
|
<artifactId>spring-oxm</artifactId>
|
||||||
<version>${spring-oxm.version}</version>
|
<version>${spring-oxm.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-context-support</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun.mail</groupId>
|
<groupId>com.sun.mail</groupId>
|
||||||
<artifactId>javax.mail</artifactId>
|
<artifactId>javax.mail</artifactId>
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package com.baeldung.spring.configuration;
|
package com.baeldung.spring.configuration;
|
||||||
|
|
||||||
import com.baeldung.spring.controller.rss.ArticleRssFeedViewResolver;
|
import java.util.ArrayList;
|
||||||
import com.baeldung.spring.controller.rss.JsonChannelHttpMessageConverter;
|
import java.util.List;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
@ -21,13 +23,12 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
import org.springframework.web.servlet.view.ContentNegotiatingViewResolver;
|
import org.springframework.web.servlet.view.ContentNegotiatingViewResolver;
|
||||||
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.baeldung.spring.controller.rss.ArticleRssFeedViewResolver;
|
||||||
import java.util.List;
|
import com.baeldung.spring.controller.rss.JsonChannelHttpMessageConverter;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
@ComponentScan(basePackages = { "com.baeldung.springmvcforms", "com.baeldung.spring.controller", "com.baeldung.spring.validator", "com.baeldung.spring.mail" })
|
@ComponentScan(basePackages = { "com.baeldung.springmvcforms", "com.baeldung.spring.controller", "com.baeldung.spring.validator", "com.baeldung.spring.mail", "com.baeldung.spring.service" })
|
||||||
public class ApplicationConfiguration implements WebMvcConfigurer {
|
public class ApplicationConfiguration implements WebMvcConfigurer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -8,9 +8,10 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
||||||
|
|
||||||
|
// needs HTTP 2 https://github.com/spring-projects/spring-framework/wiki/HTTP-2-support
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
@ComponentScan(basePackages = "com.baeldung.spring.controller.push")
|
@ComponentScan(basePackages = "com.baeldung.spring.push.controller")
|
||||||
public class PushConfiguration implements WebMvcConfigurer {
|
public class PushConfiguration implements WebMvcConfigurer {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
package com.baeldung.spring.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class RequestParamController {
|
||||||
|
|
||||||
|
@GetMapping("/api/foos")
|
||||||
|
@ResponseBody
|
||||||
|
public String getFoos(@RequestParam String id){
|
||||||
|
return "ID: " + id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/api/foos")
|
||||||
|
@ResponseBody
|
||||||
|
public String addFoo(@RequestParam(name = "id") String fooId, @RequestParam String name){
|
||||||
|
return "ID: " + fooId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/api/foos2")
|
||||||
|
@ResponseBody
|
||||||
|
public String getFoos2(@RequestParam(required = false) String id){
|
||||||
|
return "ID: " + id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/api/foos3")
|
||||||
|
@ResponseBody
|
||||||
|
public String getFoos3(@RequestParam(defaultValue = "test") String id){
|
||||||
|
return "ID: " + id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/api/foos1")
|
||||||
|
@ResponseBody
|
||||||
|
public String updateFoos(@RequestParam Map<String,String> allParams){
|
||||||
|
return "Parameters are " + allParams.entrySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/api/foos4")
|
||||||
|
@ResponseBody
|
||||||
|
public String getFoos4(@RequestParam List<String> id){
|
||||||
|
return "ID are " + id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/foos/{id}")
|
||||||
|
@ResponseBody
|
||||||
|
public String getFooById(@PathVariable String id){
|
||||||
|
return "ID: " + id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/foos")
|
||||||
|
@ResponseBody
|
||||||
|
public String getFooByIdUsingQueryParam(@RequestParam String id){
|
||||||
|
return "ID: " + id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping({"/myfoos/optional", "/myfoos/optional/{id}"})
|
||||||
|
@ResponseBody
|
||||||
|
public String getFooByOptionalId(@PathVariable(required = false) String id){
|
||||||
|
return "ID: " + id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/myfoos/optionalParam")
|
||||||
|
@ResponseBody
|
||||||
|
public String getFooByOptionalIdUsingQueryParam(@RequestParam(required = false) String id){
|
||||||
|
return "ID: " + id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.spring.controller.push;
|
package com.baeldung.spring.push.controller;
|
||||||
|
|
||||||
import javax.servlet.http.PushBuilder;
|
import javax.servlet.http.PushBuilder;
|
||||||
|
|
Loading…
Reference in New Issue