问题描述
我目前正在通过网站申请来提高编程技能.现在,我可以通过该应用程序登录该网页.现在,我的重点是让用户通过应用程序更改其个人资料并将其保存到网站.问题是网站上没有任何反应,我也没有收到任何错误代码或任何东西.
I'm currently working on my programming skills by doing a application for a website. For now I can sign in to the webpage trough the application. My focus now is to let the user change his/her's profile trough the application and save it to the website. The problem is that nothing is happening on the website and I get no error code or anything.
当我单击保存"按钮以将最近的更改保存在网站上时,我收到以下标头消息(通过使用google chrome f12->网络):
When I click the save button to save recently changes on the website I get the following header message (By using google chrome f12 -> Network):
firstname: John
lastname:Random
streetAddress:Woodstreet 12
careOfAddress:
zipCode:417 22
city:Woods
country:US
phone:111122000
languageForeignKey:4FCB3B38F96800010003004E
invoiceDeliveryMethod:email
preferredMessageMethod:sms
save_button:
utf8:✓
authenticity_token:+RadnomKey40134128Notes=
我的方法
public void setUpdatedContactInformation(String cookie, String firstName,
String lastName, String streeAdress, String coAdress,
String zipCode, String city, String country,
String alternativPhone, String language, String deliveryMethod,
String messageMethod, String token) {
try {
Response Jresponse = Jsoup
.connect(ContactInfoURL).cookie("Website-session", cookie)
.data("firstname", firstName, "lastname", lastName,
"streetAddress", streeAdress, "careOfAddress",
coAdress, "zipCode", zipCode, "city", city,
"country", country, "phone", alternativPhone,
"languageForeignKey", language,
"invoiceDeliveryMethod", deliveryMethod,
"preferredMessageMethod", messageMethod,
"authenticity_token", token)
.method(Method.POST)
.execute();
我不知道是否需要令牌,但是我还是使用了它.我可以从之前获取令牌,因此它与记录的会话相同.该函数接受的每个输入都与表单相同,我只是将名字更改为Johnnn以查看是否有效,但是在网站上未更改John.
I don't know if token is needed, but I used it anyway. I can fetch the token from before so it's the same as the logged session. Every input that the functions takes is the same as the form, I just changed the firstname to Johnnn to see if it works, but John is not changed on the website.
推荐答案
已修复!
页面上有几个按钮(顶部是搜索栏和一些导航按钮).通过编辑代码并添加我关注的按钮,可以解决此问题.新代码:
There were several buttons on the page (a search bar on the top and some navigation buttons). By editing the code and add the button that I was focusing on resolved the issue. New Code:
esponse Jresponse = .connect(ContactInfoURL).cookie("Website-session", cookie)
.data("firstname", firstName, "lastname", lastName,
"streetAddress", streeAdress, "careOfAddress",
coAdress, "zipCode", zipCode, "city", city,
"country", country, "phone", alternativPhone,
"languageForeignKey", language,
"invoiceDeliveryMethod", deliveryMethod,
"preferredMessageMethod", messageMethod, "save_button", button,
"authenticity_token", token)
.method(Method.POST)
.execute();
因此,基本上通过添加可以由F12捕获的按钮名称-> Chrome对其进行了修复. :)
So by basically adding the name of the button which can be captured by F12->Chrome fixed it. :)
这篇关于JSOUP提交POST到表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!