1.在RN中使用fetch请求外部数据
//请求参数
letformData=newFormData();
formData.append("username",this.userName);
formData.append("password",this.password);
//请求URL
leturl="http://172.16.0.236:8080/zt";
//let url = "http://172.16.0.236:8080/SpringMVC-Demo/app/loginApp";
varfetchOptions= {
method:'POST',
headers: {
'Accept':'application/json',
'Content-Type':'multipart/form-data;boundary=6ff46e0b6b5148d984f148b6542e5a5d'
},
body:data
};
fetch(url,fetchOptions)
.then((response) => response.text())
.then((responseText) => {
alert(responseText);
}).done();
2.Web端用Java接收参数
2.1 pom.xml文件中引包
2.2 application.xml配置文件中添加
2.3 Action中获取参数
HttpServletRequest request = ServletActionContext.getRequest();
System.out.println("====="+request.getParameter("password"));
或者是controller中:
@ResponseBody
@RequestMapping(value = "/app/loginApp")
public String getMonery(String username,String password) {
return "";
}