我有一个Spring控制器,它通过消息转换器将JSON映射到某些DTO对象:
export default () => (
<Page>
<Navbar title="New IoT Device" backLinkUrl="/" backLink="Back" ></Navbar>
<BlockTitle>Add a New IoI Device</BlockTitle>
<Block strong>
<List form action="http://localhost:3001/api/add-device/" method="POST" class="form-ajax-submit" id="add-device-form">
<ListInput
label="Device ID"
type="text"
placeholder="ID"
/>
<ListInput
label="Container-ID"
type="text"
placeholder="Container-ID"
/>
<ListInput type="submit" class="button" value="Button">Submit</ListInput>
</List>
</Block>
</Page>
);
让我们想象一下,我的DTO如下:
@RequestMapping(value = {"bar"},
consumes = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
public void foo(@RequestBody paramsDTO httpParams) {
// some logic here
}
是否可以通过某些Servlet或Spring上下文(而不是直接从字段)访问 public class paramsDTO {
String name;
String surName;
}
或name
值?我正在寻找类似于surName
的东西,但需要Spring JSON转换器。