Ln Project Summary-exceptions in Java

Source: Internet
Author: User

I have been working on the ln project for a while. I used eclipse to develop Java Web application for the first time. Many errors are inevitable during the debugging process. Looking at so many English letters, I sometimes feel very angry. How can this error always occur. But after debugging a few programs, you will find that there are several errors. Remember it.

 

The following describes Java exceptions and solutions for ln development.

1:404


404 is a common error for programmers. This error tells us that this path does not exist on the page you are looking. In the ln project, the main cause is that the configuration information of the current servlet is not configured in the web. xml file.

As follows:

  <servlet>    <servlet-name>DAaduitServlet</servlet-name>    <servlet-class>DAaduitServlet</servlet-class>  </servlet>  <servlet-mapping>    <servlet-name>DAaduitServlet</servlet-name>    <url-pattern>/DAaduitServlet</url-pattern>  </servlet-mapping>

2: 500


This is also a familiar error type.

The main reason is the target class, that is, the code called in this process has errors. Or the required information is empty.

The solution is to print each passed parameter value and check that the parameter is null. Determine whether the interface does not send data.

--- Why the interface does not send data

The data to be sent is not included in the form (<form> </form>. You can see this picture at a glance.


This picture shows some of the things we often encounter in the ln project. For example, form. Submission method and action usage.

 

I have summarized some other common Java errors as a reference for the future:


1. java. Lang. nullpointerexception

This exception is often encountered by everyone. The exception is explained by & quot; the program encounters a null pointer & quot;. Simply put, it calls an uninitialized object or a non-existent object, this error often occurs when you create an image. When you call an array, the image is not initialized, or the path when the image is created is incorrect. There is a null pointer in array operations. In many cases, it is a common mistake for friends who are just learning programming, that is, to confuse array initialization with array element initialization. Array initialization allocates the required space to the array. The elements in the initialized array are not instantiated and are still empty, therefore, you also need to initialize each element (if you want to call it)

 

2. java. Lang. classnotfoundexception

This exception is a problem that occurs frequently when many programmers originally developed in development environments such as JB compile the packages under JB under wtk. The exception is interpreted as & quot; the specified class does not exist & quot;. Here, we mainly consider whether the class name and path are correct. If the package is made under JB, package is usually added by default, therefore, add the package path after you go to wtk.

 

3. java. Lang. arithmeticexception

This exception is interpreted as a & quot; mathematical operation exception & quot;. For example, if an operation such as dividing by zero exists in a program, this exception occurs, we need to check whether the formula is inappropriate in the mathematical operations involved in our program.

 

4. java. Lang. arrayindexoutofboundsexception

This exception is often encountered by many friends. The exception is explained as & quot; array subscript out of bounds & quot;. Currently, most programs have Array Operations, therefore, when calling an array, you must carefully check whether the subscript you call exceeds the range of the array. In general, it is displayed (that is, the constant is used as the subscript directly) this is not easy to make calls, but implicit (that is, using variables to represent subscript) calls often encounter errors, the length of the array defined in the program is determined by some specific methods, not stated in advance. At this time, it is best to first check the length of the array to avoid this exception.

 

5. java. Lang. illegalargumentexception

This exception is interpreted as a & quot; method parameter error & quot;. Many methods in the j2s' class library may cause such errors in some situations, for example, if the volume parameter in the volume adjustment method is written as a negative number, this exception occurs, for example, G. setcolor (INT red, int green, int blue) three values in this method, if there is more than 255, this exception will also occur, so once this exception is found, what we need to do, check whether the parameter passing in the method call is incorrect.

 

6. java. Lang. illegalaccessexception

This exception is interpreted as & quot; no access permission & quot;. This exception occurs when the application calls a class but the current method does not have access permission for this class. Pay attention to this exception when package is used in the program.

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.