开发者社区> 问答> 正文

SSM框架在jsp页面获取bean报错?报错

八月 11, 2016 8:45:27 下午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://www.springframework.org/tags/form is already defined
八月 11, 2016 8:45:27 下午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://www.springframework.org/tags is already defined
八月 11, 2016 8:45:27 下午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jstl/fmt_rt is already defined
八月 11, 2016 8:45:27 下午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/scriptfree is already defined
八月 11, 2016 8:45:27 下午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jstl/fmt is already defined
八月 11, 2016 8:45:27 下午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jstl/xml is already defined
八月 11, 2016 8:45:27 下午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jsp/jstl/sql is already defined
八月 11, 2016 8:45:27 下午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
八月 11, 2016 8:45:27 下午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jstl/xml_rt is already defined
八月 11, 2016 8:45:27 下午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jstl/sql is already defined
八月 11, 2016 8:45:27 下午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jstl/sql_rt is already defined
八月 11, 2016 8:45:27 下午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/permittedTaglibs is already defined
八月 11, 2016 8:45:27 下午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jsp/jstl/xml is already defined
八月 11, 2016 8:45:27 下午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined
八月 11, 2016 8:45:27 下午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jstl/core is already defined
八月 11, 2016 8:45:27 下午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jsp/jstl/functions is already defined
八月 11, 2016 8:45:27 下午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
八月 11, 2016 8:45:27 下午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).


log4j:WARN Please initialize the log4j system properly.
八月 11, 2016 8:45:34 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-8080"]
八月 11, 2016 8:45:34 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-bio-8009"]
八月 11, 2016 8:45:34 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 20319 ms
八月 11, 2016 8:45:49 下午 org.apache.catalina.core.ApplicationDispatcher invoke
严重: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP: 


An error occurred at line: 32 in the jsp file: /WEB-INF/jsp/findUser.jsp
IUserService cannot be resolved to a type
29:     WebApplicationContext wac = WebApplicationContextUtils
30: .getWebApplicationContext(this.getServletContext());
31: //IUserDao userDao=(IUserDao)wac.getBean("userDaoImpl");
32: IUserService userService =(IUserService)wac.getBean("userServiceImpl");
33: String in=(String)request.getParameter("id");
34: System.out.println(in);
35: int number=Integer.parseInt(in);




An error occurred at line: 32 in the jsp file: /WEB-INF/jsp/findUser.jsp
IUserService cannot be resolved to a type
29:     WebApplicationContext wac = WebApplicationContextUtils
30: .getWebApplicationContext(this.getServletContext());
31: //IUserDao userDao=(IUserDao)wac.getBean("userDaoImpl");
32: IUserService userService =(IUserService)wac.getBean("userServiceImpl");
33: String in=(String)request.getParameter("id");
34: System.out.println(in);
35: int number=Integer.parseInt(in);




Stacktrace:
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:457)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:264)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1201)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:986)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:933)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:851)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
八月 11, 2016 8:45:49 下午 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet [springmvc_rest] in context with path [/liangxing] threw exception [Unable to compile class for JSP: 


An error occurred at line: 32 in the jsp file: /WEB-INF/jsp/findUser.jsp
IUserService cannot be resolved to a type
29:     WebApplicationContext wac = WebApplicationContextUtils
30: .getWebApplicationContext(this.getServletContext());
31: //IUserDao userDao=(IUserDao)wac.getBean("userDaoImpl");
32: IUserService userService =(IUserService)wac.getBean("userServiceImpl");
33: String in=(String)request.getParameter("id");
34: System.out.println(in);
35: int number=Integer.parseInt(in);




An error occurred at line: 32 in the jsp file: /WEB-INF/jsp/findUser.jsp
IUserService cannot be resolved to a type
29:     WebApplicationContext wac = WebApplicationContextUtils
30: .getWebApplicationContext(this.getServletContext());
31: //IUserDao userDao=(IUserDao)wac.getBean("userDaoImpl");
32: IUserService userService =(IUserService)wac.getBean("userServiceImpl");
33: String in=(String)request.getParameter("id");
34: System.out.println(in);
35: int number=Integer.parseInt(in);




Stacktrace:] with root cause
org.apache.jasper.JasperException: Unable to compile class for JSP: 


An error occurred at line: 32 in the jsp file: /WEB-INF/jsp/findUser.jsp
IUserService cannot be resolved to a type
29:     WebApplicationContext wac = WebApplicationContextUtils
30: .getWebApplicationContext(this.getServletContext());
31: //IUserDao userDao=(IUserDao)wac.getBean("userDaoImpl");
32: IUserService userService =(IUserService)wac.getBean("userServiceImpl");
33: String in=(String)request.getParameter("id");
34: System.out.println(in);
35: int number=Integer.parseInt(in);




An error occurred at line: 32 in the jsp file: /WEB-INF/jsp/findUser.jsp
IUserService cannot be resolved to a type
29:     WebApplicationContext wac = WebApplicationContextUtils
30: .getWebApplicationContext(this.getServletContext());
31: //IUserDao userDao=(IUserDao)wac.getBean("userDaoImpl");
32: IUserService userService =(IUserService)wac.getBean("userServiceImpl");
33: String in=(String)request.getParameter("id");
34: System.out.println(in);
35: int number=Integer.parseInt(in);




Stacktrace:
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:457)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:264)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1201)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:986)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:933)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:851)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

jsp页面

<center>
    通过controller访问<br/>
    欢迎<br/>
    <%
    WebApplicationContext wac = WebApplicationContextUtils
.getWebApplicationContext(this.getServletContext());
//IUserDao userDao=(IUserDao)wac.getBean("userDaoImpl");
IUserService userService =(IUserService)wac.getBean("userServiceImpl");  这行一直报错
String in=(String)request.getParameter("id");
System.out.println(in);
int number=Integer.parseInt(in);
    %>      
  //  <%=userDao.getUserById(number)%><br />    
    <%=userService.getString() %>>
    </center>
UserServiceImpl.java

package city.emergency.service.impl;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import city.emergency.dao.impl.UserDaoImpl;
import city.emergency.domain.User;
import city.emergency.service.IUserService;


//  这里面注解bean的名称我们都采用默认的形式,也就是类名其中首字母小写
@Service("userServiceImpl")
public class UserServiceImpl implements IUserService {
@Resource
private UserDaoImpl userDaoImpl;
public User getUserById(int id) {
return userDaoImpl.getUserById(id);
}
public String getString() {
return userDaoImpl.getString();
}
}


UserDaoImpl.java

package city.emergency.dao.impl;
import javax.annotation.Resource;


import org.springframework.stereotype.Repository;
import city.emergency.dao.IUserDao;
import city.emergency.domain.User;
import city.emergency.mapper.UserMapper;
/**
 * DAO实现层
 * @author Administrator
 *
 */
@Repository("userDaoImpl")
public class UserDaoImpl implements IUserDao{
@Resource
private UserMapper userMapper;
public User getUserById(int id) {
User user=userMapper.SelectUserById(id);
return user;
}
public String getString() {

return "本人很喜欢java开发,打算自己以后好好做出点成绩,虽然现在感觉自己效率比较低";
}


}


展开
收起
爱吃鱼的程序员 2020-06-09 11:48:37 528 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    类型转换错误····你的serviceid是userServiceImpl··(UserServiceImpl)xxx 在线等,希望各位大神帮忙一下<spanstyle="color:#222222;font-family:微软雅黑;font-size:14px;line-height:24px;background-color:#FFFFFF;">检查是否导入相应的包,在页面开头引入相应的包<%@pageimport="xx.Xx"%>见鬼的写法,模型视图的概念都忘记了?低耦合高内聚的规则也不顾了?在线等大神来解答了

    2020-06-09 11:48:54
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载