File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
web/src/main/java/demo/web/controller Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 34
34
<artifactId >lombok</artifactId >
35
35
<optional >true</optional >
36
36
</dependency >
37
+ <!-- xml数据处理-->
38
+ <dependency >
39
+ <groupId >com.fasterxml.jackson.dataformat</groupId >
40
+ <artifactId >jackson-dataformat-xml</artifactId >
41
+ </dependency >
42
+
37
43
</dependencies >
38
44
</project >
Original file line number Diff line number Diff line change 7
7
import org .hibernate .validator .constraints .Range ;
8
8
import org .springframework .beans .factory .annotation .Autowired ;
9
9
import org .springframework .beans .factory .annotation .Value ;
10
+ import org .springframework .http .MediaType ;
10
11
import org .springframework .validation .annotation .Validated ;
11
12
import org .springframework .web .bind .annotation .*;
12
13
@@ -97,11 +98,11 @@ public String task1() throws Exception {
97
98
}
98
99
99
100
/**
100
- * 参数校验1,入参为键值对形式
101
+ * 参数校验1,入参为键值对形式,返回xml格式数据
101
102
* http://localhost:8080/param?email=abc@aa.com&username=alice
102
103
* 异常类型:{@link org.springframework.validation.BindException}
103
104
*/
104
- @ RequestMapping ("/param" )
105
+ @ RequestMapping (value = "/param" , produces = MediaType . APPLICATION_XML_VALUE )
105
106
public User param (@ Valid User user ) {
106
107
return user ;
107
108
}
You can’t perform that action at this time.
0 commit comments