Struts、hibernate两框架隐藏的大问题。

严重: Exception starting filter struts2
Unable to load configuration. - bean - jar:file:/D:/apache-tomcat-7.0.77/webappsyumuseum/WEB-INFb/struts2-spring-plugin-2.3.15.1.jar!/struts-plugin.xml:29:132
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:428)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4958)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5652)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1260)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:2002)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
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:748)
Caused by: Unable to load configuration. - bean - jar:file:/D:/apache-tomcat-7.0.77/webappsyumuseum/WEB-INFb/struts2-spring-plugin-2.3.15.1.jar!/struts-plugin.xml:29:132
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:69)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415)
... 18 more
Caused by: Unable to load bean: type:com.opensymphony.xwork2.ObjectFactory class:org.apache.struts2.spring.StrutsSpringObjectFactory - bean - jar:file:/D:/apache-tomcat-7.0.77/webappsyumuseum/WEB-INFb/struts2-spring-plugin-2.3.15.1.jar!/struts-plugin.xml:29:132
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:232)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:180)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
... 20 more
Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name spring has already been loaded by bean - jar:file:/D:/apache-tomcat-7.0.77/webappsyumuseum/WEB-INFb/struts2-spring-plugin-2.2.1.jar!/struts-plugin.xml:29:132 - bean - jar:file:/D:/apache-tomcat-7.0.77/webappsyumuseum/WEB-INFb/struts2-spring-plugin-2.3.15.1.jar!/struts-plugin.xml:29:132
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:216)
... 23 more
四月 05, 2017 10:03:37 上午 org.apache.catalina.core.StandardContext startInternal

 严重: One or more Filters failed to start. Full details will be found in the appropriate container log file
四月 05, 2017 10:03:37 上午 org.apache.catalina.core.StandardContext startInternal
严重: Context [yumuseum] startup failed due to previous errors
四月 05, 2017 10:03:37 上午 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
四月 05, 2017 10:03:37 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc
严重: The web application [yumuseum] registered the JDBC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
四月 05, 2017 10:03:37 上午 org.apache.catalina.loader.WebappClassLoaderBase checkThreadLocalMapForLeaks
严重: The web application [yumuseum] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@a3baca]) and a value of type [java.lang.Class] (value [class oracle.sql.AnyDataFactory]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
四月 05, 2017 10:03:37 上午 org.apache.catalina.loader.WebappClassLoaderBase checkThreadLocalMapForLeaks
严重: The web application [yumuseum] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@1858e03]) and a value of type [java.lang.Class] (value [class oracle.sql.TypeDescriptorFactory]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
四月 05, 2017 10:03:37 上午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory D:\apache-tomcat-7.0.77\webapps\xinyumuseum has finished in 7,412 ms
四月 05, 2017 10:03:37 上午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\apache-tomcat-7.0.77\webapps\xinyumuseum.myeclipse.bak
四月 05, 2017 10:03:37 上午 org.apache.catalina.startup.TldConfig execute
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
四月 05, 2017 10:03:37 上午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory D:\apache-tomcat-7.0.77\webapps\xinyumuseum.myeclipse.bak has finished in 489 ms
四月 05, 2017 10:03:37 上午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-6060"]
四月 05, 2017 10:03:37 上午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-bio-8009"]
四月 05, 2017 10:03:37 上午 org.apache.catalina.startup.Catalina start
信息: Server startup in 67960 ms

项目完成后,部署完Tomcat 7X,运行报以上错误,代码反复推敲,然而并没有错误,甚至不开启功能,只是单纯得显示页面都无法显示,冥思苦想不通不要忘了回头看看,

接着重新创个项目,你在试试你在导项目框架得另一个顺序,你会发现一切好了,可以成功运行,

所以项目正常的导框架顺序是:Spring,hibernate,Struts2,备此谨记!!!


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
好的,您想了解关于Struts2和Hibernate框架技术实现的登录界面。这里提供一个简单的示例代码,供您参考。 首先需要搭建好Struts2和Hibernate的开发环境,然后创建一个登录页面login.jsp,包含用户名和密码输入框以及登录按钮。 login.jsp代码: ```html <html> <head> <title>Login Page</title> </head> <body> <h2>Login Page</h2> <form action="login" method="post"> <label>Username:</label> <input type="text" name="username" /> <br/><br/> <label>Password:</label> <input type="password" name="password" /> <br/><br/> <input type="submit" value="Login" /> </form> </body> </html> ``` 然后创建一个Action类LoginAction,用于处理登录请求。 LoginAction代码: ```java package com.example.action; import com.example.dao.UserDao; import com.example.entity.User; import com.opensymphony.xwork2.ActionSupport; public class LoginAction extends ActionSupport { private String username; private String password; public String execute() { UserDao userDao = new UserDao(); User user = userDao.findUserByUsernameAndPassword(username, password); if (user != null) { return SUCCESS; } else { return ERROR; } } // getters and setters } ``` 上述代码中,我们使用了一个UserDao类来访问数据库,根据输入的用户名和密码查询是否有匹配的用户。 UserDao代码: ```java package com.example.dao; import com.example.entity.User; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; public class UserDao { private SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); public User findUserByUsernameAndPassword(String username, String password) { Session session = sessionFactory.openSession(); Transaction tx = null; User user = null; try { tx = session.beginTransaction(); user = (User) session.createQuery("from User where username = :username and password = :password") .setParameter("username", username) .setParameter("password", password) .uniqueResult(); tx.commit(); } catch (Exception e) { if (tx != null) { tx.rollback(); } } finally { session.close(); } return user; } } ``` 在上述代码中,我们使用Hibernate框架来访问数据库,根据输入的用户名和密码查询是否有匹配的用户。 最后,我们需要在struts.xml文件中配置LoginAction,使得访问/login路径时可以调用LoginAction的execute方法。 struts.xml配置代码: ```xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN" "http://struts.apache.org/dtds/struts-2.5.dtd"> <struts> <package name="default" extends="struts-default"> <action name="login" class="com.example.action.LoginAction" method="execute"> <result name="success">welcome.jsp</result> <result name="error">login.jsp</result> </action> </package> </struts> ``` 在上述代码中,我们定义了一个名为login的action,它会调用LoginAction的execute方法。如果登录成功,将跳转到welcome.jsp页面,否则将继续显示login.jsp页面。 这就是一个简单的使用Struts2和Hibernate框架技术实现的登录界面的示例代码。希望能对您有所帮助。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值