servlet调用接口出错
<body>
<form action="QueryTB001" method="post">
姓名:<input type="text" name="username"><br>
密码:<input type="password" name="userpass"><br>
<input type="submit" value="登录">
</form>
</body>
@WebServlet(name = "QueryTB001", urlPatterns = { "/QueryTB001" })
public class QueryTB001 extends HttpServlet {
@Autowired
private TB001Service tb1Service;
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public QueryTB001() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.getWriter().append("Served at: ").append(request.getContextPath());
request.setCharacterEncoding("utf-8");
HttpSession session = request.getSession();
if(session==null){
session=request.getSession(true);
}
String username=request.getParameter("username");
String userpass=request.getParameter("userpass");
if (username.equals("小朱")&&userpass.equals("123456")){
session.setAttribute("username",username);
response.sendRedirect("success.jsp");
}else {
response.sendRedirect("fail.jsp");
return;
}
List<SystemParameter> sp=tb1Service.queryTB001();//到这就出错了
session.setAttribute("sp", sp);
response.sendRedirect("success.jsp");
}
public interface TB001Service {
List<SystemParameter> queryTB001();
}
@Service
public class TB001ServiceImp implements TB001Service{
@Autowired
TB001Dao tb1Dao;
public List<SystemParameter> queryTB001() {
return tb1Dao.queryTB001();
}
}
public interface TB001Dao {
List<SystemParameter> queryTB001();
}
<mapper namespace=""cn.ccut.zhm.dao.TB001Dao"">
<resultMap id="systemParameter" type="cn.edu.ccut.pojo.SystemParameter">
<id property="seqname" column="seqname"></id>
<result property="seq" column="seq"></result>
<result property="maxseq" column="maxseq"></result>
<result property="desc" column="desc"></result>
<result property="freeuse1" column="freeuse1"></result>
</resultMap>
<select id="queryTBoo1" resultMap="systemParameter">
select * from tb001
</select>
</mapper>
严重: 在路径为[/HousingProvidentFund]的上下文中,servlet[QueryTB001]的Servlet.service()引发异常
java.lang.NullPointerException
at cn.ccut.zhm.control.QueryTB001.doGet(QueryTB001.java:54)
at cn.ccut.zhm.control.QueryTB001.doPost(QueryTB001.java:64)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
好像是调用service哪里出错了,没查到### 题目描述
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
代码里有
看上去是Spring 自动装配的,但报错堆栈里有没有 Spring 的痕迹,如果没有没有配置 Spring, 检查 一下 Spring 的配置吧
是不是没有被Spring扫描到 检查一下Spring的配置