SSM框架,所有的controller都调用同一个service会不会出问题?

SSM框架,为了方便把所有的service抽取到一个公共的service,包括service的实现,Dao,Dao的实现。所有的增删改查,分页等方法全在里面。通过方法参数区分mapper,查询字段都是通过参数动态设置的。用了几个月暂时没出现大问题,我想问下,这种方式最终会不会出现某些问题?之前是一个 controller对应一个service对应一个(或多个)Dao,现在我弄的是多个controller对应一个service对应一个Dao。

3个回答

不会,只是这种方式有点不灵活

hj66666
hj66666 奥奥,谢谢,给别人写接口为了省事就弄了这么一套出来
2 年多之前 回复

只要满足业务需要,这种方式是不会出问题的。

hj66666
hj66666 嗯嗯,谢谢
2 年多之前 回复

我认为不会,只是通用方法的抽取,如果需要个性化的,就在特有的service里加上即可

hj66666
hj66666 谢谢
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
SSM框架,页面静置一段时间后,执行查询,从controller调用service函数没有立刻执行,之间隔了约20秒,怎么解决?

如题,查询页面静置一段时间后,大概5分钟,再次执行查询时,service函数没有立刻执行,可能是什么原因导致的?怎么解决? 连接的数据库是Oracle。框架用的是SSM。 Controller: ``` @Controller @RequestMapping("/tcczbquery") public class ZBQueryController { @Autowired private ZBQueryService zbQueryService; @RequestMapping("/tccqueryzb.do") @ResponseBody public JSONObject queryZB(@RequestBody QueryCondition queryCondition){ System.out.println("开始----" + System.currentTimeMillis()); System.out.println(queryCondition); System.out.println("调用queryTargets----" + System.currentTimeMillis()); Result result = zbQueryService.queryTargets(queryCondition); System.out.println(JSON.toJSONString(result)); return JSON.parseObject(JSON.toJSONString(result)); } } ``` Service: ``` @Service @Transactional public class ZBQueryServiceImpl implements ZBQueryService { @Autowired private ZBConfigMapper zbConfigMapper; @Autowired private ZBQueryOrclMapper zbQueryOrclMapper; @Autowired private ZBQueryStsMapper zbQueryStsMapper; @Override public Result queryTargets(QueryCondition condition) { System.out.println("运行queryTargets----" + System.currentTimeMillis()); Result result = new Result(); return result; } } ``` 运行截图: ![图片说明](https://img-ask.csdn.net/upload/201910/24/1571896107_804342.png)

SpringMvc中 Controller层调用多个Service方法时,事务还怎么保持?

Service方法可能是同一个Service里的 也可能是不同Service里头的方法

SSM框架controller函数参数值无法传给service函数

username和password有值也可以传递,可是进不了service函数 ![代码1](https://img-ask.csdn.net/upload/202003/31/1585628362_335875.png) ![控制台1](https://img-ask.csdn.net/upload/202003/31/1585628639_89064.png) 直接赋值没问题 ![代码2](https://img-ask.csdn.net/upload/202003/31/1585628690_839270.png) ![控制台2](https://img-ask.csdn.net/upload/202003/31/1585628754_887146.png) 传给User也没问题 ![代码3](https://img-ask.csdn.net/upload/202003/31/1585628895_280679.png) ![代码4](https://img-ask.csdn.net/upload/202003/31/1585628914_978347.png) 连这样也不行 ![代码4](https://img-ask.csdn.net/upload/202003/31/1585632608_945978.png) ![控制台4](https://img-ask.csdn.net/upload/202003/31/1585632627_419314.png) 就好像 ``` public User login(String username,String password) ``` 中的两个参数绝对进不了 ``` userService.login(username,password) ``` 函数中一样 为什么会这样!我真是想不通呀(无maven)

SSM中Controller自动注入service失败

Root Cause org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'loginController': Unsatisfied dependency expressed through field 'loginServiceImpl'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.ssm.service.LoginServiceImpl' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586) org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:364) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1269) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:551) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481) org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312) org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308) org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682) org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553) org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494) org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:171) javax.servlet.GenericServlet.init(GenericServlet.java:158) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498) org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Thread.java:745) ## 在Controller中自动注入service就报以上错误 ![图片说明](https://img-ask.csdn.net/upload/202004/13/1586763996_66970.jpg) ## 该service为 ![图片说明](https://img-ask.csdn.net/upload/202004/13/1586764249_143874.jpg) spring-dao.xml ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <!--读取properties文件 --> <context:property-placeholder location="classpath:db.properties" /> <context:annotation-config></context:annotation-config> <!--配置数据源 --> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"> <value>${driver}</value> </property> <property name="url"> <value>${url}</value> </property> <property name="username"> <value>${username}</value> </property> <property name="password"> <value>${password}</value> </property> </bean> <!-- 配置sqlsessionFactory --> <!-- 查看源码便可知注入的property的名字 --> <!-- 可以读取mybatis-config.xml文件,也可以不读取,信息全都在配置在spring中 --> <!-- <property name="configLocation" value="classpath:mybatis-config.xml" /> --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="typeAliasesPackage" value="com.ssm.bean"></property> <property name="configurationProperties"> <props> <prop key="cacheEnabled">true</prop> <prop key="lazyLoadingEnabled">false</prop> </props> </property> <!--告诉spring扫描映射文件 --> <property name="mapperLocations" value="classpath:com/ssm/dao/mapper/*.xml"></property> </bean> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.ssm.dao.mapperInterface"></property> </bean> </beans> ``` ## 以下是spring-service.xml ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <!-- 扫描添加了spring注解的类 --> <context:component-scan base-package="com.ssm.service.*" /> <!-- 采用注解方式配置 --> <context:annotation-config /> <!-- 配置事务管理器 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> <!-- 配置事务拦截器 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <!-- 注入事务属性 --> <tx:attributes> <tx:method name="get*" read-only="true" /> <tx:method name="find*" read-only="true" /> <tx:method name="select*" propagation="REQUIRED" rollback-for="Exception" /> </tx:attributes> </tx:advice> <!-- spring的aop配置 --> <aop:config proxy-target-class="true"> <aop:pointcut id="txPointcut" expression="execution(* com.ssm.service..*.*(..)) " /> <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut" /> </aop:config> </beans> ``` ## 以下spring-web.xml ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> <!-- 配置SpringMVC --> <!-- 1.开启SpringMVC注解模式 --> <!-- 简化配置: (1)自动注册DefaultAnootationHandlerMapping,AnotationMethodHandlerAdapter (2)提供一些列:数据绑定,数字和日期的format @NumberFormat, @DateTimeFormat, xml,json默认读写支持 --> <mvc:annotation-driven /> <!-- 采用注解方式配置 --> <context:annotation-config /> <!-- 2.静态资源默认servlet配置 (1)加入对静态资源的处理:js,gif,png (2)允许使用"/"做整体映射 --> <!-- <mvc:resources mapping="/images/**" location="/images/"/> <mvc:resources mapping="/js/**" location="/js/"/> <mvc:resources mapping="/css/**" location="/css/"/> <mvc:resources mapping="/fonts/**" location="/fonts/"/> <mvc:resources mapping="/script/**" location="/script/"/> --> <mvc:default-servlet-handler/> <!-- 3.配置jsp 显示ViewResolver --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <property name="prefix" value="/WEB-INF/page/" /> <property name="suffix" value=".jsp" /> </bean> <!-- 4.扫描web相关的bean --> <context:component-scan base-package="com.ssm.web.controller" /> </beans> ``` ##最后是web.xml ``` <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> <display-name>SSMDemo</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <!-- 配置spring读取的配置文件 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:spring-dao.xml classpath:spring-service.xml </param-value> </context-param> <!--配置监听器 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 如果是用mvn命令生成的xml,需要修改servlet版本为3.1 --> <!-- 配置DispatcherServlet --> <servlet> <servlet-name>SpringMVC</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <!-- 配置springMVC需要加载的配置文件 spring-dao.xml,spring-service.xml,spring-web.xml Mybatis - > spring -> springmvc --> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-web.xml</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>SpringMVC</servlet-name> <!-- 默认匹配所有的请求 --> <url-pattern>/</url-pattern> </servlet-mapping> <!-- 配置编码过滤 --> <filter> <filter-name>CharacterEncodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>CharacterEncodingFilter</filter-name> <url-pattern>/</url-pattern> </filter-mapping> </web-app> ``` ##求解决!!

ssm框架,页面跳转,执行到controller就不执行了

![图片说明](https://img-ask.csdn.net/upload/201911/09/1573280738_235403.png) ![图片说明](https://img-ask.csdn.net/upload/201911/08/1573213189_263648.png)![图片说明](https://img-ask.csdn.net/upload/201911/08/1573213201_303403.png) 进入了userlogin.action了,就不往下执行了。找不到WEB-INF/jsp下的文件,可是我的文件就放在这里边

使用ssm框架开发,一直跳转不到controller层。。。不报错。。。

``` <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <c:set var="ctx" value="${pageContext.request.contextPath }"></c:set> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" href="${ctx}/css/style.css" type="text/css" media="all"/> <title>请假的实战记录</title> <style type="text/css"> body{ background-color: #fff; } </style> </head> <body> <center> <div style="width:350px;"> <form id="myForm" action="${ctx}/lr/lrAdd">----这就是跳转的地址 <h1>添加请假记录</h1> <table> <tr> <td>姓名</td> <td><input type="text" name="name" datatype="s6-16" errormsg="姓名长度为6-16位" nullmsg="请输入姓名"/> </td> </tr> <tr> <td>请假时间</td> <td> <input type="text" name="time" onclick="WdatePicker();" nullmsg="请输入时间"/> </td> </tr> <tr> <td>请假原因</td> <td> <textarea name="reason" datadype="s1-200" errormsg="最长字数为200" nullmsg="请假原因"></textarea> </td> </tr> <tr> <td></td> <td> <input type="submit" name="" value="提交"/>&nbsp;&nbsp; <input type="reset" name="" value="清空"/> </td> </tr> </table> </form> </div> </center> <scritpt type="text/javascript" src="${ctx}/js/jquery-1.9.1.min.js"></scritpt> <scritpt type="text/javascript" src="${ctx}/js/Validform_v5.3.2_min.js"></scritpt> <scritpt type="text/javascript" src="${ctx}/js/My97DatePicker/WdatePicker.js"></scritpt> <scritpt type="text/javascript" src="${ctx}/js/My97DatePicker/calendar.js"></scritpt> <script type="text/javascript"> $(function(){ $("#myFrom").Validform(); }); </script> </body> </html> ``` ``` package com.sxt.controller; import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.sxt.pojo.Leaver; import com.sxt.service.LrService; import com.sxt.util.DateUtil; @Controller() @RequestMapping("/lr") public class AddController { @Autowired LrService lrService; @RequestMapping("/lrAdd") public String lrAdd(Leaver leaver,HttpServletRequest request){ //接收前台传送的数据 String name = request.getParameter("name"); String time = request.getParameter("time"); String reason = request.getParameter("reason"); //设置时间模式 String patten ="yyyy-MM-dd"; //将信息整合成一个对象进行传递 Leaver lea = new Leaver(name, DateUtil.str2Date(time, patten), reason); //对后台数据进行调用 int count = lrService.addLea(lea); if(count > 0){ return "redirect:/index"; }else{ return "redirect:/add"; } } } ``` 控制台不报错,F12页面信息老是显示的是404,就进不了Controller层,老是显示 lrAdd好像有问题。。 ![图片说明](https://img-ask.csdn.net/upload/201710/16/1508149012_161177.png) 控制台不报错就是浏览器就成这样了。。。很伤啊。。一下午了,搞不定。。

Java ssm 框架 访问报错500

报错如下: ``` HTTP Status 500 – Internal Server Error Type Exception Report Message Servlet.init() for servlet SpringMVC threw exception Description The server encountered an unexpected condition that prevented it from fulfilling the request. Exception javax.servlet.ServletException: Servlet.init() for servlet SpringMVC threw exception org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:341) org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783) org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1441) org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Thread.java:745) Root Cause org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.annotation.internalAsyncAnnotationProcessor': Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.aop.interceptor.AsyncExecutionInterceptor.<init>(Ljava/util/concurrent/Executor;Lorg/springframework/aop/interceptor/AsyncUncaughtExceptionHandler;)V org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:220) org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:615) org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:465) org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:663) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:629) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:677) org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:548) org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:489) org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) javax.servlet.GenericServlet.init(GenericServlet.java:158) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:341) org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783) org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1441) org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Thread.java:745) Root Cause java.lang.NoSuchMethodError: org.springframework.aop.interceptor.AsyncExecutionInterceptor.<init>(Ljava/util/concurrent/Executor;Lorg/springframework/aop/interceptor/AsyncUncaughtExceptionHandler;)V org.springframework.scheduling.annotation.AnnotationAsyncExecutionInterceptor.<init>(AnnotationAsyncExecutionInterceptor.java:60) org.springframework.scheduling.annotation.AsyncAnnotationAdvisor.buildAdvice(AsyncAnnotationAdvisor.java:150) org.springframework.scheduling.annotation.AsyncAnnotationAdvisor.<init>(AsyncAnnotationAdvisor.java:99) org.springframework.scheduling.annotation.AsyncAnnotationBeanPostProcessor.setBeanFactory(AsyncAnnotationBeanPostProcessor.java:105) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1585) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:220) org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:615) org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:465) org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:663) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:629) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:677) org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:548) org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:489) org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) javax.servlet.GenericServlet.init(GenericServlet.java:158) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:341) org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783) org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1441) org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Thread.java:745) Note The full stack trace of the root cause is available in the server logs. Apache Tomcat/8.5.12 ``` 一搭到服务器上就出现这个错误,但是本地window没问题;卡了一天了,脑瓜子呼呼的,第一次用这个玩意,实在看不出来啥问题了,有没有大佬帮忙指点指点,给条明路呀!! 下面是几个基础配置: web.xml: ``` <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <display-name>Archetype Created Web Application</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-mybatis.xml</param-value> </context-param> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <async-supported>true</async-supported> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>CORSFilter</filter-name> <filter-class>com.bls.mp.common.MyFilter</filter-class> <init-param> <param-name>excludedPages</param-name> <param-value>/UserAuthServlet</param-value> </init-param> </filter> <filter-mapping> <filter-name>CORSFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> <servlet> <servlet-name>SpringMVC</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> <async-supported>true</async-supported> </servlet> <servlet-mapping> <servlet-name>SpringMVC</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>/index.jsp</welcome-file> </welcome-file-list> </web-app> ``` spring-mvc.xml: ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd" > <!-- 自动扫描该包,使SpringMVC认为包下用了@controller注解的类是控制器 --> <context:component-scan base-package="com.bls.mp.controller"/> <!--避免IE执行AJAX时,返回JSON出现下载文件 --> <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> </list> </property> </bean> <!-- <bean id="thirdDataService" class="com.bls.mp.service.impl.ThirdDataServiceImpl"/>--> <bean class="com.bls.mp.common.SpringTool"/> <!-- 启动SpringMVC的注解功能,完成请求和注解POJO的映射 --> <!-- <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list> <ref bean="mappingJacksonHttpMessageConverter" /> JSON转换器 </list> </property> </bean>--> <!-- 定义跳转的文件的前后缀 ,视图模式配置--> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <!-- 这里的配置我的理解是自动给后面action的方法return的字符串加上前缀和后缀,变成一个 可用的url地址 --> <property name="prefix" value="/WEB-INF/resources/jsp/" /> <property name="suffix" value=".jsp" /> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property> </bean> <!-- 配置文件上传,如果没有使用文件上传可以不用配置,当然如果不配,那么配置文件中也不必引入上传组件包 --> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <!-- 默认编码 --> <property name="defaultEncoding" value="utf-8" /> <!-- 文件大小最大值 --> <property name="maxUploadSize" value="10485760000" /> <!-- 内存中的最大值 --> <property name="maxInMemorySize" value="40960" /> </bean> <!-- 全局异常处理器 --> <bean class="com.bls.mp.common.exception.CustomExceptionResolver"></bean> <mvc:annotation-driven/> <!-- 拦截器配置 --> <mvc:interceptors> <mvc:interceptor> <mvc:mapping path="/setadmin"/> <!--<mvc:mapping path="/user/userList"/> --> <mvc:mapping path="/Blocker"/> <mvc:mapping path="/goods/goods"/> <bean class="com.bls.mp.interceptor.AuthInterceptor"></bean> </mvc:interceptor> </mvc:interceptors> <task:annotation-driven/> <!-- 配置访问静态文件 --> <mvc:default-servlet-handler/> <mvc:resources location="/images/" mapping="/images/**"/> <mvc:resources location="/WEB-INF/js/" mapping="/js/**"/> <mvc:resources location="/WEB-INF/resources/jsp/" mapping="/jsp/**"/> <mvc:resources location="/WEB-INF/resources/css/" mapping="/css/**"/> </beans> ``` spring-mybatis.xml: ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"> <!-- 自动扫描 --> <context:component-scan base-package="com.bls.mp"/> <!-- 引入配置文件 --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="classpath:jdbc.properties" /> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.driver}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <!-- 初始化连接大小 --> <property name="initialSize" value="${initialSize}"></property> <!-- 连接池最大数量 --> <property name="maxActive" value="${maxActive}"></property> <!-- 连接池最大空闲 --> <property name="maxIdle" value="${maxIdle}"></property> <!-- 连接池最小空闲 --> <property name="minIdle" value="${minIdle}"></property> <!-- 获取连接最大等待时间 --> <property name="maxWait" value="${maxWait}"></property> </bean> <!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <!-- 自动扫描mapping.xml文件 --> <property name="mapperLocations" value="classpath:com/bls/mp/mapping/*.xml"></property> </bean> <!-- DAO接口所在包名,Spring会自动查找其下的类 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.bls.mp.dao" /> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property> </bean> <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> </beans> ``` jdk版本: 1.8.0_222 tomcat 版本:8.0 有没有大佬来给看看呀0.0

使用SSM框架配置式开发(不用注解),为何Service中无法注入Dao?

我用Intellij Idea开发的,所以配置文件中出错会标识红色,spring-service.xml中的ref="IStudentDao"部分出错。 另外我用Maven做的项目管理,不知道是不是配置文件放置的路径有问题。附上我的项目目录结构:![图片说明](https://img-ask.csdn.net/upload/201704/17/1492434652_95958.png) 部署到Tomcat上启动后,报No adapter for handler [com.bruceliao.controller.StudentController@12bc3bf8]: The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler Mybatis配置文件: ``` <configuration> <!--别名--> <typeAliases> <package name="com.bruceliao.beans"/> </typeAliases> <!--Mapper的位置--> <mappers> <package name="com.bruceliao.dao"/> </mappers> </configuration> ``` Spring配置文件: spring-mybatis.xml ``` <!--注册sqlSessionFactory--> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="configLocation" value="classpath:mybatis.xml"/> <property name="dataSource" ref="dataSource"/> </bean> <!--生成Dao代理对象--> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/> <property name="basePackage" value="com.bruceliao.dao"/> </bean> ``` spring-service.xml ``` <!--注册Service--> <bean id="studentService" class="com.bruceliao.service.impl.StudentServiceImpl"> <property name="studentDao" ref="IStudentDao"/> </bean> ``` spring-mvc.xml ``` <bean id="/view/login.do" class="com.bruceliao.controller.StudentController"> <property name="studentService" ref="studentService"/> </bean> ``` ![图片说明](https://img-ask.csdn.net/upload/201704/17/1492435263_528738.png)

SSM项目,启用service注解失败

我是一个新手,写一个项目,用git和maven搭了个SSM框架,启动tomcat的时候报这个错误,可是service接口里,却一点错误没有,请教大神怎么解决![这是错误信息](https://img-ask.csdn.net/upload/201612/16/1481898669_439279.jpg) ![图片说明](https://img-ask.csdn.net/upload/201612/16/1481898703_223163.jpg) ![![图片说明](https://img-ask.csdn.net/upload/201612/16/1481898758_986884.jpg)

在service层里调用了dao的两个方法,如何保证这两个方法执行在同一个事务中呢?

service里有如下方法 Java code@Transactional(rollbackFor = Exception.class) public boolean del(Integer id) { boolean b = false; b = backDao.del(id); Back bs = new Back(); bs.setUserName(null); backDao.save(bs); return b; } 我想实现的是只用当删除和保存都正确的情况下,才持久化到数据库中去,现在我调用这个del方法时,保存明显是错误的,插入不到数据库中去,而且后台也报错了,但是还是可以删除操作的 dao中方法如下,继承了SqlMapClientDaoSupport Java codepublic boolean delete(final String sqlId, final PK pk) { boolean flag = false; try { this.getSqlMapClientTemplate().delete(sqlId, pk); flag = true; } catch (Exception e) { e.printStackTrace(); } return flag; } public boolean save(final String sqlId, final T entity) { boolean flag = false; try { this.getSqlMapClientTemplate().insert(sqlId, entity); flag = true; } catch (Exception e) { e.printStackTrace(); } return flag; } 还有一个问题,怎么能保证save,del等方法正确执行呢,我是用返回一个boolean型来判断的,如果抛异常就说明没有成功执行,但是我感觉不太好

关于SSM整合报Service层错误问题

``` org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'commandController': Unsatisfied dependency expressed through field 'service': Error creating bean with name 'serviceImp': Unsatisfied dependency expressed through field 'userMapper': No qualifying bean of type [com.cwj.backoffice.web.mapper.UserMapper] found for dependency [com.cwj.backoffice.web.mapper.UserMapper]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.cwj.backoffice.web.mapper.UserMapper] found for dependency [com.cwj.backoffice.web.mapper.UserMapper]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'serviceImp': Unsatisfied dependency expressed through field 'userMapper': No qualifying bean of type [com.cwj.backoffice.web.mapper.UserMapper] found for dependency [com.cwj.backoffice.web.mapper.UserMapper]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations : {@org.springframework.beans.factory.annotation.Autowired(required=true)}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.cwj.backoffice.web.mapper.UserMapper] found for dependency [com.cwj.backoffice.web.mapper.UserMapper]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:350) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:775) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5181) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5704) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1018) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:994) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652) at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1900) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:619) at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:566) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:468) at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468) at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76) at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309) at java.security.AccessController.doPrivileged(Native Method) at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1408) at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357) at sun.rmi.transport.Transport$1.run(Transport.java:200) at sun.rmi.transport.Transport$1.run(Transport.java:197) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:196) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'serviceImp': Unsatisfied dependency expressed through field 'userMapper': No qualifying bean of type [com.cwj.backoffice.web.mapper.UserMapper] found for dependency [com.cwj.backoffice.web.mapper.UserMapper]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.cwj.backoffice.web.mapper.UserMapper] found for dependency [com.cwj.backoffice.web.mapper.UserMapper]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:350) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:187) at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1208) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1048) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1018) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:570) ... 62 more Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.cwj.backoffice.web.mapper.UserMapper] found for dependency [com.cwj.backoffice.web.mapper.UserMapper]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1398) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1051) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1018) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:570) ... 76 more 浜旀湀 14, 2019 10:52:08 涓嬪崍 org.apache.catalina.core.ApplicationContext log 淇℃伅: Log4jServletContextListener ensuring that Log4j starts up properly. 浜旀湀 14, 2019 10:52:08 涓嬪崍 org.apache.catalina.core.ApplicationContext log 淇℃伅: Log4jServletContextListener ensuring that Log4j shuts down properly. 浜旀湀 14, 2019 10:52:08 涓嬪崍 org.apache.catalina.core.ApplicationContext log 淇℃伅: Closing Spring root WebApplicationContext ``` 求大佬帮帮忙,已经找了一天了,UserMapper还有Service一直报错。 ``` package com.cwj.backoffice.web.mapper; import com.cwj.backoffice.web.User.Items; import com.cwj.backoffice.web.User.User; import java.util.List; public interface UserMapper { public void save(User user); public List<Items> select(); } <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.cwj.backoffice.web.mapper.UserMapper"> <insert id="save" parameterType="user"> INSERT INTO t_user(id,username,password) values(#{id},#{username},#{password}); </insert> <select id="select" resultType="items"> SELECT * FROM t_user; </select> </mapper> ``` ``` package com.cwj.backoffice.web.UserService; import com.cwj.backoffice.web.User.Items; import com.cwj.backoffice.web.User.User; import java.util.List; public interface Service { public void save(User user); public List<Items> select(); } /** * Copyright (C), 2015-2019, XXX有限公司 * FileName: ServiceImp * Author: 50427 * Date: 2019/5/14 18:43 * Description: * History: * <author> <time> <version> <desc> * 作者姓名 修改时间 版本号 描述 */ package com.cwj.backoffice.web.UserService.Imp; import com.cwj.backoffice.web.User.Items; import com.cwj.backoffice.web.User.User; import com.cwj.backoffice.web.UserService.Service; import com.cwj.backoffice.web.mapper.UserMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.List; /** * 〈一句话功能简述〉<br> * 〈〉 * * @author 50427 * @create 2019/5/14 * @since 1.0.0 */ @org.springframework.stereotype.Service public class ServiceImp implements Service { @Autowired UserMapper userMapper; @Override public void save(User user) { userMapper.save(user); } @Override public List<Items> select() { return userMapper.select(); } } ```

求各位大牛解决ssm 框架service注入dao为空

controller: package com.haier.rrs.controller; @Controller @RequestMapping("/register") public class RegisterController { @Autowired private UserService userService; @RequestMapping("/doregister.do") @ResponseBody public String doregister(HttpServletRequest request){ String username = request.getParameter("username"); String pwd = request.getParameter("password"); EndecryptUtils endecrypUtil =new EndecryptUtils(); User user=endecrypUtil.md5Password(username, pwd); int n=userService.registerUser(user); return "/success.jsp"; } } service层 接口service已经@service: package com.haier.rrs.service.impl; public class UserServiceImpl implements UserService{ private UserDao userDao; public UserDao getUserDao() { return userDao; } public void setUserDao(UserDao userDao) { this.userDao = userDao; } @Override public User doUserLogin(User user) { // TODO Auto-generated method stub return userDao.doUserLogin(user); } @Override public int registerUser(User user) { // TODO Auto-generated method stub、 String username="1"; List<User> lt = new ArrayList(); lt=userDao.selectAll(); List<User> us=userDao.selectId(username); int n=userDao.addUser(user); return n; } } Dao层: package com.haier.rrs.dao; @Repository public interface UserDao { List<User> selectId(@Param(value = "username") String username); public User doUserLogin(User user); public int addUser(User user); List<User> selectAll(); } spring-user.xml <bean id="userDao" class="org.mybatis.spring.mapper.MapperFactoryBean" parent="baseDAO"> <property name="mapperInterface" value="com.haier.rrs.dao.UserDao" /> </bean> <!-- Service --> <bean id="userService" class="com.haier.rrs.service.impl.UserServiceImpl"> <property name="userDao" ref="userDao"/> </bean> spring-mybatis.xml <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="classpath:jdbc.properties" /> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${driver}" /> <property name="url" value="${url}" /> <property name="username" value="${username}" /> <property name="password" value="${password}" /> <!-- 初始化连接大小 --> <property name="initialSize" value="${initialSize}"></property> <!-- 连接池最大数量 --> <property name="maxActive" value="${maxActive}"></property> <!-- 连接池最大空闲 --> <property name="maxIdle" value="${maxIdle}"></property> <!-- 连接池最小空闲 --> <property name="minIdle" value="${minIdle}"></property> <!-- 获取连接最大等待时间 --> <property name="maxWait" value="${maxWait}"></property> </bean> <!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <!-- 自动扫描mapping.xml文件 --> <property name="mapperLocations" value="classpath:/mybatis/**/*Mapper.xml"></property> </bean> <!-- DAO接口所在包名,Spring会自动查找其下的类 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.haier.rrs.dao" /> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property> </bean> <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> 我也不知道哪出问题了,网上的都试了,不行![图片说明](https://img-ask.csdn.net/upload/201707/05/1499251268_936330.png)

SSM的serviceImpl中调用dao接口的方法报空指针异常,求大神支招

用SSM写的项目,需要实现的功能是从第三方接口获取数据,然后将数据保存到服务器上的数据库,数据获取正常,但是调用dao接口的方法是报空指针异常,请问是什么原因![![图片说明](https://img-ask.csdn.net/upload/201709/21/1505956943_524842.jpg)图片说明](https://img-ask.csdn.net/upload/201709/21/1505956934_524659.png)

ssm框架怎样从后段获取model类型数据返回到jsp页面弹窗显示?

``` public String deleteNewslabel(int id,Model model){ try { service.deleteNewslabel(id); }catch (DataIntegrityViolationException e) { model.addAttribute("message", "存在子栏目,无法删除!"); } return "/desktop/news/queryNewslabel.do"; } ``` 这是后台页面,因为删除的数据是外键,设置的是无法删除,将提示保存message中,请问如何在jsp页面中弹窗提示无法删除? 下面是前台代码 ``` <td class="td07"><a href="${pageContext.request.contextPath }/desktop/news/deleteNewslabel.do?id=${data.id }" onclick="return shanchu()" >删除</a></td> ```

ssm 框架已经实现,但是ajax返回验证有毛病

``` <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>js+ajax</title> <script type="text/javascript" src="static/bootstrap/js/jquery-2.0.3.js"></script> <script type="text/javascript"> function validate(){ var name= $("#name").val(); if(name==null||name==""){ //为空隐藏提交按钮 var ui =document.getElementById("tijiao"); ui.style.display="none"; //这里是简单的显示 不设计后台,前台做的判断 $("#namediv").html("用户名不可以为空"); }else{ //ajax实现 //11111111获取XMLhtmlRequestxml对象 var req=createXmlHttpRequest(); //222222222准备url 数据 回调函数 //这个name是function下面var的参数. var url="/maven/reg1.do?name="+name; //还有一个参数表示的是异步还是同步,一般不写直接就是true,异步的 req.open("GET",url,true); //3333333333这个就是回调函数 req.onreadystatechange=callback; //这个send是在从servlet判断你的账号是不是存在, 如果是true就说名字存在,给页面返回了以后才有的.为啥写空不知道 //4发送请求 req.send(null); //回调函数 function callback(){ //第一个是我们的服务器成功接受了响应,并且解释了出来,状态4 第二个是服务器内部没有发生错误, url什么的也没有错, if(req.readyState=4&&req.status==200){ var date=req.responseText; if(date=="false"){ //下面的是意思是,如果账号存在了,提交按钮自动消失 //超级叼 var ui =document.getElementById("tijiao"); ui.style.display="none"; $("#namediv").html("用户名已经存在"); }else{ //不为空了,按钮一直显示 var ui =document.getElementById("tijiao"); ui.style.display=""; $("#namediv").html("用户名可以使用"); } } } } } function createXmlHttpRequest(){ //如果是ie6以上版本的浏览器 if(window.XMLHttpRequest){ return new XMLHttpRequest(); }else{ //如果浏览器是ie以下的 return new ActiveXObject("Microsoft.XMLHTTP"); } } </script> </head> <body> <form action="/maven/reg1.do" id="form1"> <table id="aa"> <tr> <td>用户名</td> <td><input type="text" name="username" id="name" onblur="validate();" />&nbsp;<font color="red">*</font></td> <td> <div id="namediv" style="display: inline"></div> </td> <td>密码</td> <td><input type="password" name="password"></td> <td>电话</td> <td><input type="text" name="phone"></td> <td><input type="submit" value="点击注册" id="tijiao"></td> </tr> </table> </form> </body> </html> ``` ``` ``` ``` package com.gray.user.controller; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpRequest; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import com.gray.user.entity.RegUser; import com.gray.user.service.impl.RegServiceImpl; import com.gray.user.service.impl.UserServiceImpl; @Controller public class RegController { @Autowired private RegServiceImpl userService; //自动装载他到spring @RequestMapping("/reg1.do") //url public String dologin(Model model,HttpServletResponse res,@RequestParam String username,RegUser rg,HttpServletResponse response) throws IOException{ boolean used=false; System.out.println("测试参数获取到bean没有"+rg.getUsername()+rg.getPassword()+rg.getPhone()); rg.setUsername(username); if(userService.doUserLogin(rg)){ used=true; System.out.println("通过control到--->service---到dao---到usermapp.在返回回来,service里面是ture,就是说账号不重复"); }else{ used=false; System.out.println("通过control到--->service---到dao---到usermapp.在返回回来,service里面是false,重复了账号 "); } return "regsuccess"; } } ``` ``` package com.gray.user.service.impl; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.gray.user.dao.UserDao; import com.gray.user.entity.RegUser; import com.gray.user.entity.User; import com.gray.user.service.RegService; import com.gray.user.service.UserService; @Service public class RegServiceImpl implements RegService { @Autowired private UserDao<RegUser> dao; @Override public boolean doUserLogin(RegUser ruser) { //第一次执行查询数据库,查询 userdao selectUserName方法。 他这个方法和user.xml里面的id为selectUserName串联了. //也就是直接调用查询语句,并且吧值返回给reguser 类 System.out.println("testRegServiceImpl------->查询数据库,查询语句为id是selectusername"); List<RegUser> list = dao.selectUserName(ruser.getUsername()); System.out.println("查到了集合大小是"+list.size()+"查到了和你账号相同是的是几个"); if(list.size() == 0){ System.out.println("RegServiceImpl---你没有查询到你账号和数据库相同的信息.所以你return,"); for(int i=0;i<list.size();i++){ System.out.println(list.get(i).getUsername()); } return true; }else{ if(list.size()!=0){ System.out.println("regServiceImpl---查询到和你相同的账号不是0个,返回false"); return false; }else{ System.out.println("regserviceImpl----其他情况我也不知道啥情况,也返回false"); return false; } } } } ``` ``` 页面上的ajax 他就一直出毛病,数据库有个账号名是aa 只有我在表单填写aa 他才在网页提示账号重复, 别的任何都不提示,只会提示不能为空, 而且还失灵时不灵。 但是用system. 输出 我写的任何判断都是对了, 这是为啥? 请求大神给我说下,最好说下哪里错了。谢谢了

spring +springmvc+mybatis,service中调用dao接口报空

搭建ssm,启动项目没问题,但是在service实现类中调用dao接口时,对象loginDao对象是空的,错误信息如下 ![图片说明](https://img-ask.csdn.net/upload/201512/27/1451212017_76737.png) log4j:ERROR Error occured while converting date. java.lang.NullPointerException at java.lang.System.arraycopy(Native Method) at java.lang.AbstractStringBuilder.getChars(Unknown Source) at java.lang.StringBuffer.getChars(Unknown Source) at org.apache.log4j.helpers.ISO8601DateFormat.format(ISO8601DateFormat.java:130) at java.text.DateFormat.format(Unknown Source) at org.apache.log4j.helpers.PatternParser$DatePatternConverter.convert(PatternParser.java:443) at org.apache.log4j.helpers.PatternConverter.format(PatternConverter.java:65) at org.apache.log4j.PatternLayout.format(PatternLayout.java:506) at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:310) at org.apache.log4j.WriterAppender.append(WriterAppender.java:162) at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251) at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66) at org.apache.log4j.Category.callAppenders(Category.java:206) at org.apache.log4j.Category.forcedLog(Category.java:391) at org.apache.log4j.Category.log(Category.java:856) at org.apache.commons.logging.impl.Log4JLogger.debug(Log4JLogger.java:177) at org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.resolveException(AbstractHandlerExceptionResolver.java:132) at org.springframework.web.servlet.DispatcherServlet.processHandlerException(DispatcherServlet.java:1148) at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:985) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:917) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:824) at javax.servlet.http.HttpServlet.service(HttpServlet.java:643) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:798) at javax.servlet.http.HttpServlet.service(HttpServlet.java:723) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 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:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:620) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Unknown Source)

SSM 遇到的java.lang.NullPointerException问题

报错 java.lang.NullPointerException ** at com.archives.controller.sysmanage.DepartmentController.doPageData(DepartmentController.java:38) ** at com.archives.controller.sy****smanage.DepartmentController.initHome(DepartmentController.java:32) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:220) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:134) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) at javax.servlet.http.HttpServlet.service(HttpServlet.java:624) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 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:505) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2517) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2506) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) mapper.xml 文件 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.archives.dao.UserDeptDao"> <resultMap id="userdeptMap" type="com.archives.entity.UserDept"> <id column="deptid" property="deptid"></id> <result column="deptname" property="deptname"/> <result column="telephone" property="telephone"/> <result column="fax" property="fax"/> <result column="managerid" property="managerid"/> <result column="remark" property="remark"/> <association property="userInfo" javaType="com.archives.entity.UserInfo"> <id column="loginid" property="loginid"></id> <result column="loginname" property="loginname"/> <result column="loginpwd" property="loginpwd"/> <result column="realname" property="realname"/> <result column="roleid" property="roleid"/> <result column="leveid" property="leveid"/> <result column="cardid" property="cardid"/> <result column="dutyid" property="dutyid"/> <result column="deptid" property="deptid"/> <result column="joindate" property="joindate"/> <result column="telephone" property="telephone"/> <result column="enduid" property="enduid"/> <result column="address" property="address"/> <result column="sex" property="sex"/> </association> </resultMap> <select id="selectUserDeptCount" parameterType="com.archives.model.A0104Model" resultType="Integer"> select count(*) as cnt from userinfo,dept and userinfo.deptid = dept.deptid <if test="loginname != null and loginname.trim() != '' "> and userinfo.loginname = #{loginname} </if> <if test="realname != null and realname.trim() != '' "> and userinfo.realname = #{realname} </if> <if test="deptname != null and deptname.trim() != '' "> and dept.deptname = #{deptname} </if> </select> <select id="selectUserDeptList" parameterType="com.archives.model.A0104Model" resultMap="userdeptMap"> select userinfo.loginid , userinfo.loginname , userinfo.realname , dept.deptname , dept.deptid from userinfo,dept where userinfo.deptid = dept.deptid limit #{offsetindex},#{pageCount} </select> </mapper> controller.java文件 package com.archives.controller.sysmanage; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.alibaba.fastjson.JSON; import com.archives.common.Constant; import com.archives.entity.Menu; import com.archives.entity.UserDept; import com.archives.entity.UserInfo; import com.archives.model.A0104Model; import com.archives.service.HomeService; import com.archives.service.UserDeptService; @Controller @RequestMapping("/department") public class DepartmentController { UserDeptService userdeptService; @RequestMapping("/init") public String initHome(HttpServletRequest request) { A0104Model model=new A0104Model(); model.setCurPage(1); model.setPageCount(Constant.PAGE_COUNT); 对应的错误行**doPageData(request,model);** return "department"; } private void doPageData(HttpServletRequest request, A0104Model model) { // TODO Auto-generated method stub int cnt = userdeptService.selectUserDeptCount(model); int totalPage = 0; if(cnt%Constant.PAGE_COUNT == 0) { totalPage = cnt/Constant.PAGE_COUNT; }else { totalPage = cnt/Constant.PAGE_COUNT + 1; } model.setTotalPage(totalPage); model.setOffsetindex((model.getCurPage() - 1) * Constant.PAGE_COUNT); model.setPageCount(Constant.PAGE_COUNT); 对应的错误行**List<UserDept> userdeptduiyList=userdeptService.selectUserDeptList(model);** request.setAttribute("userdeptList", userdeptList); request.setAttribute("model", model); } } model.java文件 package com.archives.model; public class A0104Model { private String loginname; private String realname; private String deptname; public String getLoginname() { return loginname; } public void setLoginname(String loginname) { this.loginname = loginname; } public String getRealname() { return realname; } public void setRealname(String realname) { this.realname = realname; } public String getDeptname() { return deptname; } public void setDeptname(String deptname) { this.deptname = deptname; } public int getCurPage() { return curPage; } public void setCurPage(int curPage) { this.curPage = curPage; } public int getTotalPage() { return totalPage; } public void setTotalPage(int totalPage) { this.totalPage = totalPage; } public int getOffsetindex() { return offsetindex; } public void setOffsetindex(int offsetindex) { this.offsetindex = offsetindex; } public int getPageCount() { return pageCount; } public void setPageCount(int pageCount) { this.pageCount = pageCount; } private int curPage; private int totalPage; private int offsetindex; private int pageCount; } Dao package com.archives.dao; import java.util.List; import com.archives.entity.UserDept; import com.archives.model.A0104Model; public interface UserDeptDao { UserDeptDao getUserDeptByName(String loginname); int selectUserDeptCount(A0104Model model); List<UserDept> selectUserDeptList(A0104Model model); } service package com.archives.service; import java.util.List; import com.archives.entity.UserDept; import com.archives.model.A0104Model; public interface UserDeptService { int selectUserDeptCount(A0104Model model); List<UserDept> selectUserDeptList(A0104Model model); } serviceImpl package com.archives.service; import java.util.List; import com.archives.dao.UserDeptDao; import com.archives.entity.UserDept; import com.archives.model.A0104Model; public class UserDeptServiceImpl implements UserDeptService { UserDeptDao userdeptDao; @Override public int selectUserDeptCount(A0104Model model) { // TODO Auto-generated method stub int cnt=userdeptDao.selectUserDeptCount(model); return cnt; } @Override public List<UserDept> selectUserDeptList(A0104Model model) { // TODO Auto-generated method stub List<UserDept> userdeptList =userdeptDao.selectUserDeptList(model); return userdeptList; } } UserDept.java package com.archives.entity; public class UserDept { private int deptid; private String deptname; private String telephone; private String fax; private String managerid; private String remark; public String getTelephone() { return telephone; } public void setTelephone(String telephone) { this.telephone = telephone; } public String getFax() { return fax; } public void setFax(String fax) { this.fax = fax; } public String getManagerid() { return managerid; } public void setManagerid(String managerid) { this.managerid = managerid; } public String getRemark() { return remark; } public void setRemark(String remark) { this.remark = remark; } public int getDeptid() { return deptid; } public void setDeptid(int deptid) { this.deptid = deptid; } public String getDeptname() { return deptname; } public void setDeptname(String deptname) { this.deptname = deptname; } public String getLoginid() { return loginid; } public void setLoginid(String loginid) { this.loginid = loginid; } public String getLoginname() { return loginname; } public void setLoginname(String loginname) { this.loginname = loginname; } public String getRealname() { return realname; } public void setRealname(String realname) { this.realname = realname; } private String loginid; private String loginname; private String realname; }

spring mvc 怎么使用action属性连接controller方法

web项目spring mvc框架中的jsp页面使用action 连接controller中已有的方法, “action="http://localhost:8080/demo/model/create"”这样写 会报错 说找不到这个方法

我用的是spring mvc+mybatis,问一下service层应该都需要写什么

我想问一下service层,dao层,control层都应该写什么? 我们项目经理说 service层只要写一个dao引用,service和表是一一对应的, 我觉得service既然是业务层是不是所有业务相关的都要写? 比如学生,班级,成绩三个表 我们现在是对应学生表有一个增删改查的dao和service, 对应班级表有一个增删改查的dao和service, 对应成绩表有一个增删改查的dao和service, 如果查询及格的学生的班级和姓名 是不是要在学生control里调用成绩和班级的service? 还是在学生service实现类里调用成绩和班级的service来获得结果呢? 真不知道代码规范是什么。求有经验的大神详细讲解一下谢谢了

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

你以为这样写Java代码很6,但我看不懂

为了提高 Java 编程的技艺,我最近在 GitHub 上学习一些高手编写的代码。下面这一行代码(出自大牛之手)据说可以征服你的朋友,让他们觉得你写的代码很 6,来欣赏一下吧。 IntStream.range(1, 5).boxed().map(i -&gt; { System.out.print("Happy Birthday "); if (i == 3) return "dear NAME"...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

程序员写出这样的代码,能不挨骂吗?

当你换槽填坑时,面对一个新的环境。能够快速熟练,上手实现业务需求是关键。但是,哪些因素会影响你快速上手呢?是原有代码写的不够好?还是注释写的不够好?昨夜...

带了6个月的徒弟当了面试官,而身为高级工程师的我天天修Bug......

即将毕业的应届毕业生一枚,现在只拿到了两家offer,但最近听到一些消息,其中一个offer,我这个组据说客户很少,很有可能整组被裁掉。 想问大家: 如果我刚入职这个组就被裁了怎么办呢? 大家都是什么时候知道自己要被裁了的? 面试软技能指导: BQ/Project/Resume 试听内容: 除了刷题,还有哪些技能是拿到offer不可或缺的要素 如何提升面试软实力:简历, 行为面试,沟通能...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

程序员为什么千万不要瞎努力?

本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

Python爬虫,高清美图我全都要(彼岸桌面壁纸)

爬取彼岸桌面网站较为简单,用到了requests、lxml、Beautiful Soup4

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

Java岗开发3年,公司临时抽查算法,离职后这几题我记一辈子

前几天我们公司做了一件蠢事,非常非常愚蠢的事情。我原以为从学校出来之后,除了找工作有测试外,不会有任何与考试有关的事儿。 但是,天有不测风云,公司技术总监、人事总监两位大佬突然降临到我们事业线,叫上我老大,给我们组织了一场别开生面的“考试”。 那是一个风和日丽的下午,我翘着二郎腿,左手端着一杯卡布奇诺,右手抓着我的罗技鼠标,滚动着轮轴,穿梭在头条热点之间。 “淡黄的长裙~蓬松的头发...

大牛都会用的IDEA调试技巧!!!

导读 前天面试了一个985高校的实习生,问了他平时用什么开发工具,他想也没想的说IDEA,于是我抛砖引玉的问了一下IDEA的调试用过吧,你说说怎么设置断点...

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

立即提问
相关内容推荐