Why is the registration page refreshed once, the database has a more data?????

Source: Internet
Author: User

  

Why does the Web project click the Register button to jump to the registration page? (Previous blog post)

Since the last registration page was successfully accessed (previous blog), I started writing the registration page. Finally, the user name and password are successfully inserted into the database!

But there's a problem! I login just registered page, the system began to error!!

Nested exception is org.apache.ibatis.exceptions. toomanyresultsexception:expected One result (or null) to being returned by SelectOne (), but found:2 atOrg.mybatis. Spring. Mybatisexceptiontranslator.translateexceptionifpossible (mybatisexceptiontranslator.java:75) at Org.mybatis.spring.sqlsessiontemplate$sqlsessioninterceptor.invoke (sqlsessiontemplate.java:371) at Com.sun.proxy . $Proxy 6.selectOne (Unknown Source)

  See the red font I guess it's time to log in from the database to find two user names!

Why do you have two usernames??? To check the database, found that I have just registered the user name is really repeated! (The user name is not a primary key, so it can be unique)

Very doubtful why is two, so I registered a user name, found that the database is also two ....

I do not think that, when I register should only have a user name Ah, inadvertently found that whenever I refresh the page, the database will be more than a duplicate record.

It's hard to understand why this is so!

Later I found the problem, that is, when I completed the registration, jump to the login page, the URL is not changed!!!     Because I'm using a forward! The difference between redirection and forwarding is not detailed here.

Here I only explain the URL in the forwarding address bar will not change!!!

So, when I completed the registration jump to the login page, my URL has not changed, is still the URL of the registration page. Plus my request for a GET request, the parameters are all on the URL.

Http://localhost:8080/springmvc_mybatis1110/login.action?usercode=123&password=123

So, whenever I refresh the page, it will invoke the interface of the registration function, the database will be one more data!

Then the problem was found;

Here to solve the problem

The problem is simple, will be redirected to redirect to the login page, the URL will be changed to the URL of the login page, so that the database will not be inexplicable increase data!

Why is the registration page refreshed once, the database has a more data?????

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.