action路径java.null_严重:路径为[/家庭作业]的上下文中的Servlet[ProfileServlet]的Servlet.service()引发异常java.lang.NumberFo...

我有个例外,我不知道为什么。它说它的a数字格式异常为空。我看过其他关于这个的帖子,但是没有一篇能解决我的问题。我的profile类是一个简单的类,它有id username lastname age和favTeam以及setters、getter和构造函数。有人知道为什么会这样吗?

public ProfileServlet() {

super();

}

/**

* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)

*/

HashMap team = new HashMap();

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException

{

response.setContentType("application/json; charset=UTF-8");

//String requestUrl = request.getRequestURI();

PrintWriter out = response.getWriter();

Profile test = new Profile();

int id;

test = team.get(id = Integer.parseInt(request.getParameter("ID")));

if(test != null)

{

out.println("ID: " + test.getId());

out.println("name: " + test.getUsername());

out.println("lastname: " + test.getLastname());

out.println("age: " + test.getAge());

out.println("favTeam: " + test.getFavTeam());

}

else

{

//ERROR

}

}

/**

* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)

*/

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException

{

String id = request.getParameter("id");

String age = request.getParameter("id");

int x = 0;

if(id!=null){

try{

x = Integer.parseInt(id);

}catch(Exception e){

}

}

String username = request.getParameter("username");

String lastname = request.getParameter("lastname");

String favTeam = request.getParameter("favTeam");

int numage = 0;

if(id!=null){

try{

numage = Integer.parseInt(age);

}catch(Exception e){

}

}

Profile profile = new Profile(x,username,lastname,favTeam,numage);

team.put(profile.getId(),profile);

}

}

我的.xml

Homework

ProfileServlet

ntrut.ProfileServlet

ProfileServlet

/profile

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值