网站建设安全制度图片,怎么做简易网页,长沙人才招聘网,创意设计作品欣赏例如#xff0c;下面的类RegisterResponse 使用了XmlRootElement注解#xff0c;同时也使用XmlType注解#xff0c;并用XmlType注解的propOrder属性#xff0c;指定了两个用XmlElement注解的元素出现的顺序#xff0c;先出现flag#xff0c;后出现enterpriseId#xff0…例如下面的类RegisterResponse 使用了XmlRootElement注解同时也使用XmlType注解并用XmlType注解的propOrder属性指定了两个用XmlElement注解的元素出现的顺序先出现flag后出现enterpriseId在xml中的元素名称是body
package com.thb.server.register;import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlType;/*** 该类映射到http响应的xml* author thb**/
//使用了JAXB注解映射到xml中的response元素
XmlRootElement(name response)
XmlType(propOrder {flag, enterpriseId})
public class RegisterResponse {private String flag;private String enterpriseId;public RegisterResponse() {}//使用了JAXB注解映射到xml中的flag元素XmlElement(name flag, required true)public String getFlag() {return this.flag;}public void setFlag(String flag) {this.flag flag;}//使用了JAXB注解映射到xml中的body元素XmlElement(name body, required true)public String getEnterpriseId() {return this.enterpriseId;}public void setEnterpriseId(String enterpriseId) {this.enterpriseId enterpriseId;}}生成XML schema显示顺序是flag在前body在后
用Postman发送http请求得到的响应是flag在前body在后
作为对比如果上面的类不使用XmlType注解即变为下面这样
XmlRootElement(name response)
public class RegisterResponse {
...生成XML schema是body在前flag在后
用Postman发送http请求得到的响应是是body在前flag在后