servlet-求解决,总是报NullPointerException

问题描述

求解决,总是报NullPointerException

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
IncomeTypeService itservice = new IncomeTypeServiceImpl();
HttpSession session=request.getSession();
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
String incomeTypeName=request.getParameter("incomeTypeName");
int incomeTypeNo= Integer.parseInt(request.getParameter("incomeTypeNo"));
System.out.println(incomeTypeNo+":"+incomeTypeName);
try{
IncomeType incomeType = itservice.findIncomeTypeByIncomeTypeName(incomeTypeName);
//这里可以输出数据
System.out.println(incomeTypeNo+":"+incomeTypeName);

        //NullPointerException
        incomeType.setIncomeTypeName(incomeTypeName);
        incomeType.setIncomeTypeNo(incomeTypeNo);
        itservice.updateIncomeType(incomeType);

2015-12-12 23:41:12 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet [UpdateIncomeTypeServlet] in context with path [/financialManager] threw exception
java.lang.NullPointerException
at com.dyh.familyfinancialmanager.servlet.incometype.UpdateIncomeTypeServlet.doPost(UpdateIncomeTypeServlet.java:38)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.dyh.familyfinancialmanager.filter.EncodeFilter.doFilter(EncodeFilter.java:27)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:619)

求解决啊!!!

解决方案

检查下你的incomeType是否为空

解决方案二:

值没有传过来吧。能不能打印一下

解决方案三:

IncomeTYpename是否为空?数据类型是什么?

解决方案四:

int incomeTypeNo= Integer.parseInt(request.getParameter("incomeTypeNo"));
String incomeTypeName=request.getParameter("incomeTypeName");

System.out.println(incomeTypeNo+":"+incomeTypeName);
111:工资

解决方案五:

空指针,很简单,说明哪个指针变量是空的,问题出在你给变量赋值的地方。好好看,这是最简也是培养好习惯的地方。

解决方案六:

at com.dyh.familyfinancialmanager.filter.EncodeFilter.doFilter(EncodeFilter.java:27)
看一下你filter有没有什么限制

时间: 2024-11-08 18:56:40

servlet-求解决,总是报NullPointerException的相关文章

jax ws-通过wsdl生成webservice,调用时报错求解决

问题描述 通过wsdl生成webservice,调用时报错求解决 客户端,报com.sun.xml.ws.server.UnsupportedMediaException 解决方案 错误提示了,web service需要使用Content Type为text/xml 解决方案二: 能详细说一下吗?刚自学java 解决方案三: 请检查服务器和客户端的SOAP版本是不是一样. 另外参考C# 调用 jax-ws 时的问题 这个问题是解决了, 确实版本问题, jdk6默认是soap1.1 增加 @Bin

imageloader-Imagrloader 的library 导入全是错误 求解决

问题描述 Imagrloader 的library 导入全是错误 求解决 老是报那个asseration 有错误 不想要jar文件的 因为看不见源码 求助 解决方案 参考:http://blog.csdn.net/braddoris/article/details/41542023

mysql数据库报如下错误,跪求解决

问题描述 mysql数据库报如下错误,跪求解决 --- The error happened while setting a property on the result object. --- Cause: com.ibatis.common.beans.ProbeException: Could not get property 'dynamicFields' from com.aspire.ess.domain.Accounts. Cause: java.lang.ClassCastExc

java定时器 run方法怎么返回值 我要返回result 代码里一直报错 晚生跪求解决

问题描述 java定时器 run方法怎么返回值 我要返回result 代码里一直报错 晚生跪求解决 public VirementResultInfo queryTransaction( final String bank, final TransactionInfo transactionInfo) { // final VirementResultInfo result = null; TimerTask task = new TimerTask() { @Override public v

sping mvc 工程报错,求解决。

问题描述 sping mvc 工程报错,求解决. 大神,帮我看看怎么解决. 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean wit

java-tomcat部署probe报错 求解决

问题描述 tomcat部署probe报错 求解决 问题如图所示: probe是直接下载的2.3.3的版本

android-网上的方法都试过了,软件也重装了,Android studio 报错,求解决,在线等..

问题描述 网上的方法都试过了,软件也重装了,Android studio 报错,求解决,在线等.. Error:Unable to start the daemon process. This problem might be caused by incorrect configuration of the daemon. For example, an unrecognized jvm option is used. Please refer to the user guide chapter

ava android-不明原因的函数报错,求解决

问题描述 不明原因的函数报错,求解决 public double std(double a[],int b) { double c=0.0; double d=0.0; for(int i=0;i<b;i++) c=c+(a[i]-mean(a,b))*(a[i]-mean(a,b)); d=Math.sqrt(c/b); return(d); } 在最下面的有报错:Syntax-error-insert-to-complete-lass-ody,不过同样结构写的其他几个函数就没问题啊 解决方案

reportViewer 运行报错 求解决 新手

问题描述 reportViewer 运行报错 求解决 新手 : Report1.rdlc生成操作也改成内容 解决方案 Jboss运行WebService报错解决