In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about the small problems encountered in Java Servlet, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.
I only recently started to learn Java Servlet. Today, I wrote a Mini Program of Java Servlet for login verification. When I finished, I compiled and passed, but when I entered the user and password and jumped to the Welcome screen, something strange happened. In my welcom.Java program, I can accept the user name and password of the login page, but I can't accept the form read from the database. It took me more than half a day to find out the cause of the error. The statement with the problem is as follows:
Pstm=con.prepareStatement ("select*fromuserslimit" + (pageSize* (pageNow-1)) + ", 3")
There seems to be no problem with this sentence, but the problem lies in this place: (pageSize* (pageNow-1)). I added an extra parenthesis here. When I wrote this, I thought (pageSize* (pageNow-1)) and pageSize* (pageNow-1) were the same, no problem. I used to write this way when I wrote Java programs, and there were no mistakes, but today I fell on these parentheses and spent most of my day looking for errors. At first, I thought this problem appeared in the writing format of the table, but I looked for it for a long time, but I didn't find anything wrong with the writing format of the form. I felt that there was no mistake. I was really devastated. As long as I came to ask for help with my online friends, my online friends prompted me if there was something wrong with my connection to the database. So I started to focus on the database program again, so I wondered if I was trying to put
Pstm=con.prepareStatement ("select*fromuserslimit" + (pageSize* (pageNow-1)) + ", 3")
Change to: pstm=con.prepareStatement ("select*fromuserslimit0,3")
Haha, sure enough, when I opened the program, my program worked properly, so I thought that the problem must lie in (pageSize* (pageNow-1)), but this (pageSize* (pageNow-1)) did not see anything wrong. When I removed the parentheses outside, ah, the program was normal, although I don't know why I couldn't access the database with extra parentheses in (pageSize* (pageNow-1)). But I am still very happy, because I have found the problem all the time, and I will notice it when I write a similar program in the future.
After reading the above, do you have any further understanding of the minor problems encountered in Java Servlet? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.