急急急急!!用eclipse向mysql数据库写入时的错误,一点提交就这样,拜托拜托!!空指针怎么改呢?
HTTPStatus500-typeExceptionreportmessagedescriptionTheserverencounteredaninternalerro...
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
com.tjau.StrawberryLv.servlet.AddSpecialServlet.doPost(AddSpecialServlet.java:46)
javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.55 logs.
报错的代码:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("UTF-8");
String s_tName = request.getParameter("s_tName").toString().trim();//这是46行报错那里
String s_dName = request.getParameter("s_dName").toString().trim();
String s_place = request.getParameter("s_place").toString().trim();
float s_price = Float.parseFloat(request.getParameter("s_price").toString().trim());
String s_intrude = request.getParameter("s_intrude").toString().trim();
Special special = new Special();
special.setS_tName(s_tName);
special.setS_dName(s_dName);
special.setS_place(s_place);
special.setS_price(s_price);
special.setS_intrude(s_intrude);
ISpecialBiz specialBiz = new SpecialBizImpl();
boolean flag = specialBiz.add(special);
request.setAttribute("msgcode", 200);
RequestDispatcher dispatcher = request.getRequestDispatcher("addSpecial.jsp");
dispatcher.forward(request, response);
} 展开
type Exception report
message
description The server encountered an internal error that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
com.tjau.StrawberryLv.servlet.AddSpecialServlet.doPost(AddSpecialServlet.java:46)
javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.55 logs.
报错的代码:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("UTF-8");
String s_tName = request.getParameter("s_tName").toString().trim();//这是46行报错那里
String s_dName = request.getParameter("s_dName").toString().trim();
String s_place = request.getParameter("s_place").toString().trim();
float s_price = Float.parseFloat(request.getParameter("s_price").toString().trim());
String s_intrude = request.getParameter("s_intrude").toString().trim();
Special special = new Special();
special.setS_tName(s_tName);
special.setS_dName(s_dName);
special.setS_place(s_place);
special.setS_price(s_price);
special.setS_intrude(s_intrude);
ISpecialBiz specialBiz = new SpecialBizImpl();
boolean flag = specialBiz.add(special);
request.setAttribute("msgcode", 200);
RequestDispatcher dispatcher = request.getRequestDispatcher("addSpecial.jsp");
dispatcher.forward(request, response);
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询