问题描述
您好,我是 Struts 的新手,并试图在 struts 中向世界打招呼,但我遇到了错误.我正在尝试解决它但无法做到.错误信息是
Hi I am new in Struts and trying to hello world in struts but I got error. I am trying to fixed it out but unable to do. The error message is
EVERE: Exception starting filter struts2 Unable to load configuration. - bean - jar:file:/home/sudarshan/Desktop/RestFullTuts/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/struts2starter/WEB-INF/lib/struts2-portlet-plugin-2.3.28.jar!/struts-plugin.xml:31:133 at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:496) at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57) 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:4574) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5193) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399) 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:745) Caused by: Unable to load configuration. - bean - jar:file:/home/sudarshan/Desktop/RestFullTuts/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/struts2starter/WEB-INF/lib/struts2-portlet-plugin-2.3.28.jar!/struts-plugin.xml:31:133 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70) at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:970) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:438) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:482) ... 14 more
我的 struts.xml 文件是
My struts.xml file is
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://www.51sjk.com/Upload/Articles/1/0/333/333666_20221021153823842.dtd"> <struts> <package name="default" extends="struts-default"> <action name="getTutorial" class="com.sudarshan.action.TutorialAction"> <result name="success">success.jsp</result> <result name="failure">error.jsp</result> </action> </package> </struts>
Web.xml 是
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.51sjk.com/Upload/Articles/1/0/333/333666_20221021153823920.jpg" xmlns="http://www.51sjk.com/Upload/Articles/1/0/333/333666_20221021153824420.jpg" xsi:schemaLocation="http://www.51sjk.com/Upload/Articles/1/0/333/333666_20221021153824420.jpg http://www.51sjk.com/Upload/Articles/1/0/333/333666_20221021153824420.jpg/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> <display-name>struts2starter</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> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
那么这段代码的解决方案是什么.
so what is the solution for this code.
推荐答案
从类路径中移除 struts2-portlet-plugin-2.3.28.jar.但是对于管理库的解决方案,您可以使用 Maven.
Remove struts2-portlet-plugin-2.3.28.jar from the classpath. But for the solution to manage libraries you can use Maven.
查看使用 Maven 构建的教程:使用 Maven 创建 Struts 2 Web 应用程序以管理工件并构建应用程序.
See the tutorial that is built with Maven: Create Struts 2 Web Application Using Maven To Manage Artifacts and To Build The Application.
使用下载的最小依赖项
<dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> <version>2.3.28</version> </dependency>