我正在编写一个 XSD 来验证一个 XML,但是当我验证这个错误时出现了:
输出 - 错误
使用 XML 模式验证当前文件:
错误:元素“{ http://www.w3.org/2001/XMLSchema-instance }Gasto”:不需要此元素。预期是(加斯托)
......我不明白这个错误
这是我的 XML 示例:
<?xml version="1.0" encoding="UTF-8"?>
<Armazem>
<Lista_Gastos xmlns:artGasto="http://www.w3.org/2001/XMLSchema-instance"
artGasto:noNamespaceSchemaLocation="TraXSD.xsd">
<artGasto:Gasto id="50">
<artGasto:nome>Robalo</artGasto:nome>
<artGasto:quantidade>1</artGasto:quantidade>
</artGasto:Gasto>
</Lista_Gastos>
</Armazem>
Run Code Online (Sandbox Code Playgroud)
这是我的 XSD 示例:
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema elementFormDefault="qualified"
attributeFormDefault="unqualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:artGasto="http://www.w3.org/2001/XMLSchema-instance">
<xsd:element name="Armazem">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Lista_Gastos"
type="TListGastos" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="TListGastos">
<xsd:sequence >
<xsd:element name="Gasto" type="TGasto"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="TGasto">
<xsd:sequence >
<xsd:element name="nome" type="xsd:string" />
<xsd:element name="quantidade" type="xs:integer" />
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string" use="required"/> …Run Code Online (Sandbox Code Playgroud) 我正在做一个具有这种关系的应用程序:一个个人联系人有一封电子邮件。
因此,我试图从个人联系人中查找电子邮件,并且使用Criteria进行此查询,但始终返回IllegalArgumentException:
@Override
public Email findByEmail(PersonalContact personalContact) {
CriteriaBuilder criteriaBuilder = entityManager().getCriteriaBuilder();
CriteriaQuery<Email> criteriaQuery = criteriaBuilder.createQuery(Email.class);
Root<Email> email = criteriaQuery.from(Email.class);
criteriaQuery.where(criteriaBuilder.equal(
email.get("personalContact"), criteriaBuilder.parameter(PersonalContact.class, "personalContact")));
TypedQuery<Email> typedQuery = entityManager().createQuery(criteriaQuery);
typedQuery.setParameter("personalContact", personalContact);
return typedQuery.getSingleResult();
}
Run Code Online (Sandbox Code Playgroud)
个人联系就像一个外键。
这是我的电子邮件课程:
@Entity
@Table(name = "Email")
public class Email implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String mainEmail;
private List<String> secondaryMail;
@JoinColumn(name = "personal")
@OneToOne(fetch = FetchType.LAZY)
private PersonalContact pContact;
Run Code Online (Sandbox Code Playgroud)
这是我的个人联系人课程:
@Entity
@Table(name = …Run Code Online (Sandbox Code Playgroud) 我正在用 javascript 编写一些代码,我打算做一个方法,将请求发送到 web api 并接收一个令牌作为回报(尚未完成)。
这是我的代码
$.ajax({
type: 'POST',
crossDomain: true, //For cors on web api
crossOrigin: true,
xhrFields: {
withCredentials: true, //send the credentials
},
contentType: 'application/x-www-form-urlencoded',
url: 'https://localhost:44123/Token',
grant_type: 'password',
username: username,
password: password,
success: function () {
alert("success");
},
error: function (xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response
alert(xhr.status);
alert(xhr.responseText);
},
});
Run Code Online (Sandbox Code Playgroud)
但是每次我执行该方法时,都会收到以下错误:
错误 400(发布)--> unsupported_grant_type
我不习惯 ajax/js ......所以我有点迷茫......有什么想法吗?——