Static Final Long serialVersionUID = 1L
本问题已经有最佳答案,请猛点这里访问。
Possible Duplicate:
What is a serialVersionUID and why should I use it?
what is meant by that in a servlet (private static final long serialVersionUID = 1L)?
我有一个简单的问题,关于我们的教授给出的这个指导计划。我已经看过好几次了,但我不知道这是为了什么。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | package module; import java.io.IOException; import java.io.PrintWriter; import java.util.Scanner; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * @author JA */ public class Servlet_1 extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet{ static final long serialVersionUID = 1L; public void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("txt/html"); ServletOutputStream out = response.getOutputStream(); out.println("<html>"); out.println("<head>Hello Panget</head>"); out.println("<body>"); out.println("Hello Panget"); out.println("</body></html>"); } protected void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Write your program here, Panget. } } |
这就是为什么:
http://frequeual.com/java/practicalserialversionidguidelines.html
这不是强制性的,但在可能的情况下应该添加。不过不疼。