我的申请
我的applicationContext与WEB_INF / spring / root-context.xml中的root-context.xml一样。它在web.xml中使用
声明<context:component-scan base-package="com.sat.spring">
</context:component-scan>
<annotation-driven />
<resources mapping="/resources/**" location="/resources/" />
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
</beans:beans>
我的调度程序servlet xml位于WEB-INF / spring / appServlet.servlet-context.xml中,其中包含我的
<!-- Root Context: defines shared resources visible to all other web components -->
<context:property-placeholder location="classpath:jdbc.properties" />
<context:component-scan base-package="com.sat.spring">
<context:exclude-filter expression="org.springframework.stereotype.Controller"
type="annotation" />
</context:component-scan>
<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.databaseurl}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.sat.spring.model" />
<property name="annotatedClasses">
<list>
<value>com.sat.spring.model.User</value>
</list>
</property>
<!-- <property name="configLocation"> <props > <prop key="hi"></prop> </props>
</property> -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">hibernate.hbm2ddl.auto</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="show_sql">true</prop>
<prop key="format_sql">true</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="persistenceExceptionTranslationPostProcessor"
class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor">
</bean>
<bean id="userDao" class="com.sat.spring.daoImpl.UserDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
</beans>
位于WEB-INF / spring文件夹中的我的root-context.xml是:
<body>
<form:form action="submit" modelAttribute="userForm" method="POST">
<table>
<tr>
<td><form:input path="name" /></td>
<td><form:label path="name"> Name </form:label></td>
</tr>
<tr>
<td><form:input path="id" /></td>
<td><form:label path="id"> password </form:label></td>
</tr>
<tr>
<td><form:input path="password" /></td>
<td><form:label path="password"> password </form:label></td>
</tr>
<tr>
<td><input type="submit" value="Submit" /> </table>
</form:form>
</body>
我的登录jsp是
@RequestMapping(value = "/submit", method = RequestMethod.POST)
public String saveOrUpdateUser(@ModelAttribute("userForm") User user,
BindingResult result, Model model) {
ApplicationContext ac = new FileSystemXmlApplicationContext("WEB-INF/spring/root-context.xml");
UserDao dao = (UserDao) ac.getBean("UserDao");
Session session;
int status = userdao.save(user);
System.out.println("----status---" + status);
System.out.println("name is: "+user.getName()+ "password is"+user.getPassword());
String name = user.getName();
int id = user.getId();
String pw = user.getPassword();
model.addAttribute("name", name);
model.addAttribute("pw", pw);
model.addAttribute("ID", id);
return "registered";
}
名称,ID和密码中的用户密钥以及login.jsp使用action = / submit
命中mvc控制器public class UserDaoImpl implements UserDao {
@Autowired
private SessionFactory sessionFactory;
public SessionFactory getSessionFactory() {
return sessionFactory;
}
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
public UserDaoImpl() {
}
public UserDaoImpl(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
@Transactional
public int save(User user) {
Session session;
try {
session = sessionFactory.getCurrentSession();
session.saveOrUpdate(user);
} catch (HibernateJdbcException e) {
session = sessionFactory.openSession();
}
return 0;
}
}
我的DaoImpl是
# MYSQL Driver
jdbc.driverClassName =com.mysql.jdbc.Driver
jdbc.databaseurl =jdbc:mysql://localhost:3306/uniprojectdb
jdbc.username=root
jdbc.password=root
我的jdbc.properties文件是
HTTP Status 500 - Request processing failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from file [B:\STS\sts-bundle\sts-3.7.1.RELEASE\WEB-INF\spring\root-context.xml]; nested exception is java.io.FileNotFoundException: WEB-INF\spring\root-context.xml (The system cannot find the path specified
当我运行应用程序时,我转到使用java1.8在Tomcat 7上运行的login.jsp页面。 填写login.jsp上的字段后,点击提交按钮后,我得到:
Oct 14, 2016 6:39:17 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.8.0_45\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_101/bin/server;C:/Program Files/Java/jre1.8.0_101/bin;C:/Program Files/Java/jre1.8.0_101/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\xampp\mysql\bin\;C:\Python34;C:\Program Files\Java\jdk1.8.0_45\\bin; C:\Program Files\Apache\apache-maven-3.3.3\bin;C:\Program Files\Apache\apache-maven-3.3.3\bin;C:\Program Files (x86)\Common Files\Ulead Systems\MPEG;C:\Program Files (x86)\Skype\Phone\;B:\STS\sts-bundle\sts-3.7.1.RELEASE;;.
Oct 14, 2016 6:39:17 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:UniversityProject08' did not find a matching property.
Oct 14, 2016 6:39:17 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:SpringMVCJdbc03' did not find a matching property.
Oct 14, 2016 6:39:18 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Oct 14, 2016 6:39:18 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Oct 14, 2016 6:39:18 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1491 ms
Oct 14, 2016 6:39:18 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Oct 14, 2016 6:39:18 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
Oct 14, 2016 6:39:18 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [117] milliseconds.
Oct 14, 2016 6:39:19 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(B:\UniversityProject-STS\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\SpringMVCJdbc03\WEB-INF\lib\javaee-web-api-7.0.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
Oct 14, 2016 6:39:21 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Oct 14, 2016 6:39:21 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Oct 14, 2016 6:39:21 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization started
Oct 14, 2016 6:39:21 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFO: Refreshing Root WebApplicationContext: startup date [Fri Oct 14 18:39:21 EDT 2016]; root of context hierarchy
Oct 14, 2016 6:39:21 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [spring/application-config.xml]
Oct 14, 2016 6:39:22 PM org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
INFO: Loaded JDBC driver: com.mysql.jdbc.Driver
Oct 14, 2016 6:39:22 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization completed in 994 ms
Oct 14, 2016 6:39:22 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'dispatcherServlet'
Oct 14, 2016 6:39:22 PM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'dispatcherServlet': initialization started
Oct 14, 2016 6:39:22 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'dispatcherServlet-servlet': startup date [Fri Oct 14 18:39:22 EDT 2016]; parent: Root WebApplicationContext
Oct 14, 2016 6:39:22 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/mvc-config.xml]
Oct 14, 2016 6:39:23 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod
INFO: Mapped "{[/save],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.spring.controllers.StudentController.save(com.spring.model.Student)
Oct 14, 2016 6:39:23 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod
INFO: Mapped "{[/option],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.spring.controllers.StudentController.option(com.spring.model.Student,org.springframework.validation.BindingResult,org.springframework.ui.ModelMap)
Oct 14, 2016 6:39:23 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod
INFO: Mapped "{[/registered],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.spring.controllers.StudentController.registered(com.spring.model.Student)
Oct 14, 2016 6:39:23 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod
INFO: Mapped "{[/viewstudent],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.spring.controllers.StudentController.viewStudent()
Oct 14, 2016 6:39:23 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod
INFO: Mapped "{[/deleteStudent],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.spring.controllers.StudentController.deletStudent(com.spring.model.Student)
Oct 14, 2016 6:39:23 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod
INFO: Mapped "{[/studentform],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.spring.controllers.StudentController.showform()
Oct 14, 2016 6:39:23 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod
INFO: Mapped "{[/deletedStudent],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.spring.controllers.StudentController.dele(com.spring.model.Student)
Oct 14, 2016 6:39:23 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod
INFO: Mapped "{[/editStudent],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.spring.controllers.StudentController.edit(com.spring.model.Student)
Oct 14, 2016 6:39:23 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod
INFO: Mapped "{[/edit],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.spring.controllers.StudentController.editStudent(int,com.spring.model.Student,org.springframework.validation.BindingResult,org.springframework.ui.ModelMap)
Oct 14, 2016 6:39:23 PM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'dispatcherServlet': initialization completed in 1038 ms
Oct 14, 2016 6:39:25 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Oct 14, 2016 6:39:25 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Fri Oct 14 18:39:25 EDT 2016]; root of context hierarchy
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/root-context.xml]
INFO : org.springframework.context.support.PropertySourcesPlaceholderConfigurer - Loading properties file from class path resource [jdbc.properties]
INFO : org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
WARN : org.hibernate.cfg.SettingsFactory - Unrecognized value for "hibernate.hbm2ddl.auto": hibernate.hbm2ddl.auto
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 2288 ms
Oct 14, 2016 6:39:27 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'appServlet'
INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'appServlet': initialization started
INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing WebApplicationContext for namespace 'appServlet-servlet': startup date [Fri Oct 14 18:39:27 EDT 2016]; parent: Root WebApplicationContext
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]
INFO : org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[//],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.sat.spring.controller.HomeController.home()
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[//home],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.sat.spring.controller.HomeController.home(java.util.Locale,org.springframework.ui.Model)
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/login],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.sat.spring.controller.LoginController.login()
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/submit],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.sat.spring.controller.LoginController.saveOrUpdateUser(com.sat.spring.model.User,org.springframework.validation.BindingResult,org.springframework.ui.Model)
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter - Looking for @ControllerAdvice: WebApplicationContext for namespace 'appServlet-servlet': startup date [Fri Oct 14 18:39:27 EDT 2016]; parent: Root WebApplicationContext
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter - Looking for @ControllerAdvice: WebApplicationContext for namespace 'appServlet-servlet': startup date [Fri Oct 14 18:39:27 EDT 2016]; parent: Root WebApplicationContext
INFO : org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'appServlet': initialization completed in 620 ms
Oct 14, 2016 6:39:28 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Oct 14, 2016 6:39:28 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Oct 14, 2016 6:39:28 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 10431 ms
INFO : org.springframework.context.support.FileSystemXmlApplicationContext - Refreshing org.springframework.context.support.FileSystemXmlApplicationContext@626daf5e: startup date [Fri Oct 14 18:39:38 EDT 2016]; root of context hierarchy
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from file [B:\STS\sts-bundle\sts-3.7.1.RELEASE\WEB-INF\spring\root-context.xml]
Oct 14, 2016 6:39:38 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [appServlet] in context with path [/spring] threw exception [Request processing failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from file [B:\STS\sts-bundle\sts-3.7.1.RELEASE\WEB-INF\spring\root-context.xml]; nested exception is java.io.FileNotFoundException: WEB-INF\spring\root-context.xml (The system cannot find the path specified)] with root cause
java.io.FileNotFoundException: WEB-INF\spring\root-context.xml (The system cannot find the path specified)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at org.springframework.core.io.FileSystemResource.getInputStream(FileSystemResource.java:115)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:216)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:187)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:251)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:452)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
at com.sat.spring.controller.LoginController.saveOrUpdateUser(LoginController.java:44)
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:497)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:781)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:721)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
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:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
并在控制台上:
fileprivate func getCurrenUserHighResImageURL() -> String? {
var photoURLOutput : String?
let graphRequest : FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: ["fields" : "picture.type(large)"])
graphRequest.start(completionHandler: { connection, result , error -> Void in
if ((error) != nil) {
print("Error: \(error)")
} else {
let castedResult = result as? [String : AnyObject]
if let castedResult = castedResult {
if let photURL = castedResult["picture"] as? [String : AnyObject] {
let photoData = photURL["data"] as? [String : AnyObject]
photoURLOutput = photoData?["url"] as? String
if let photoURLOutput = photoURLOutput {
CURRENT_USER_URL.updateChildValues(["highResImageURL" : "\(photoURLOutput)"])
}
}
}
}
})
return photoURLOutput
}
我正在使用mySQL数据库但没有保存/持久存在。我做错了什么?请帮忙......谢谢
答案 0 :(得分:0)
如果您点击&#34;提交&#34; - 按钮,则调用方法saveOrUpdateUser()
。您构造一个FileSystemXmlApplicationContext
指向&#34; WEB-INF / spring / root-context.xml&#34;那里。但是这个位置评估为&#34; B:\ STS \ sts-bundle \ sts-3.7.1.RELEASE \ WEB-INF \ spring \ root-context.xml&#34;在运行时期间在您的系统上由于您的应用程序打包在war文件中,因此无法找到文件root-context.xml。
解决方案:
没有必要创建FileSystemXmlApplicationContext
,因为已经创建了使用root-context.xml的WebApplicationContext
(请参阅您的日志),因为您的web.xml。您应该使用此上下文并让Spring为UserDao
(@Autowired)注入依赖项。