首页 > 代码库 > @SuppressWarnings("deprecation")

@SuppressWarnings("deprecation")

在Java编译过程中会出现很多警告,有很多是安全的,但是每次编译有很多警告影响我们对error的过滤和修改,我们可以在代码中加上

@SuppressWarnings(“XXXX”) 来解决

@SuppressWarnings("deprecation")表示不去检测这个下面的方法是否被启用。

例如:

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
User u=new User();
u.setUname(request.getParameter("Uname"));
u.setUpwd(request.getParameter("Upwd"));
u.setAddress(request.getParameter("address"));
String temp[]=request.getParameter("birthday").split("-");
@SuppressWarnings("deprecation")
Date date =new Date(Integer.parseInt(temp[0])-1900,Integer.parseInt(temp[1])-1,Integer.parseInt(temp[2]));//这一句应该有警告,表示此方法已过时.

具体参数及说明请参考:

http://blog.csdn.net/u013209460/article/details/32325015

 

@SuppressWarnings("deprecation")