java类型错误java.lang.Integer cannot be cast to java.lang.String
spring framwork DAO的基类(下面代码忽略注解,那个应该没错)
public class HibernateCommonImpDAO<T extends Serializable, ID extends Serializable>extends HibernateDaoSupport { [color=#FF0000]public ID save(T transientObject) { return (ID) super.getSession().save(transientObject);[/color] }}
public class LoginServiceImp implements LoginService public String saveUser(LoginResource loginResource){ [color=#FF0000]return (String)loginResourceDAO.save(loginResource);[/color] }}
@RequestMapping(value="/regeditSave.do") public String regeditSave(HttpServletRequest request,Model model) throws Exception { HttpSession session = request.getSession(); try { LoginResource user = new LoginResource(); [color=#FF0000]loginService.saveUser(user);[/color] session.setAttribute("sessionUser", user); } catch(Exception e) { e.printStackTrace(); } return "welcome";//跳转到欢迎界面 }
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:852)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:584)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1508)
at java.lang.Thread.run(Thread.java:619)
错误地方是知道了,但是怎么解决请大家教教我~~
[解决办法]
是你这个部错了
(String)loginResourceDAO.save(loginResource)
loginResourceDAO.save(loginResource) 返回值应该是int 类型 转换成string 时候 出错 你好好看看吧
[解决办法]
integer转换成String类型失败。 在需要integer转换成String的时候,后面加""就行了