Struts2:Map$Entry解析错误与Action未映射解决方案

需积分: 48 64 下载量 56 浏览量 更新于2024-09-09 1 收藏 275KB DOC 举报
在Struts2开发过程中,开发者可能遇到一个关于Java类型的解析错误,即"无法解析类型java.util.Map$Entry。从必需的.class文件间接引用了它"。这个问题通常出现在使用Java Development Kit (JDK) 1.8.0_45及以上版本,并且与JRE版本不匹配时。当你使用较新的JDK版本而项目中的JRE版本较低(如1.7.0_45或更低)时,Map$Entry类可能未被正确加载。 解决此问题的步骤如下: 1. **检查构建路径设置**: - 右键点击JRE系统库,选择"构建路径"(英文名Build Path)。 - 在构建配置路径中,确保你选择了正确的JRE版本。对于JDK 1.7.0_45,你需要选择这个版本的JRE,如果尚未安装,需要添加并配置。 - 完成配置后,记得刷新项目以应用更改。 2. **更新JRE版本**: - 如果需要,确保你的项目中安装了多个JRE版本,以便在编译时可以选择合适的JDK支持。 报错2:"There is no Action mapped for namespace[/] and action name[login]"是另一个常见问题,表示找不到指定的Action。解决方法包括: - **struts.xml配置**: - 首先,确认struts.xml文件的名称(通常为struts.xml)和位置。struts2默认查找这个文件,不需要在web.xml中额外配置,但要确保文件位于WEB-INF/classes目录,而不是src目录(虽然IDE可能自动处理这种情况,但在实际部署环境中,WEB-INF/classes是标准放置位置)。 - **表单配置**: - 在使用自定义命名空间的Form表单时,确保正确声明了命名空间属性。 - **action的name属性**: - 在struts.xml中配置Action时,检查name属性是否填写正确,尤其是在小型项目中,通常使用默认命名空间即可,除非有特殊需求。 - **类文件存在性**: - 确保在classes目录下有对应于配置中Action的类文件,类文件的存在是Action能够被找到的基础。 通过这些步骤,你可以解决这两个与Struts2相关的报错,确保项目能够正常运行。同时,保持JDK和JRE版本的一致性以及正确管理项目的配置文件,是避免此类问题的关键。
2018-10-17 上传
org.apache.http.ConnectionClosedException.class org.apache.http.ConnectionReuseStrategy.class org.apache.http.Consts.class org.apache.http.ContentTooLongException.class org.apache.http.ExceptionLogger.class org.apache.http.FormattedHeader.class org.apache.http.Header.class org.apache.http.HeaderElement.class org.apache.http.HeaderElementIterator.class org.apache.http.HeaderIterator.class org.apache.http.HttpClientConnection.class org.apache.http.HttpConnection.class org.apache.http.HttpConnectionFactory.class org.apache.http.HttpConnectionMetrics.class org.apache.http.HttpEntity.class org.apache.http.HttpEntityEnclosingRequest.class org.apache.http.HttpException.class org.apache.http.HttpHeaders.class org.apache.http.HttpHost.class org.apache.http.HttpInetConnection.class org.apache.http.HttpMessage.class org.apache.http.HttpRequest.class org.apache.http.HttpRequestFactory.class org.apache.http.HttpRequestInterceptor.class org.apache.http.HttpResponse.class org.apache.http.HttpResponseFactory.class org.apache.http.HttpResponseInterceptor.class org.apache.http.HttpServerConnection.class org.apache.http.HttpStatus.class org.apache.http.HttpVersion.class org.apache.http.MalformedChunkCodingException.class org.apache.http.MessageConstraintException.class org.apache.http.MethodNotSupportedException.class org.apache.http.NameValuePair.class org.apache.http.NoHttpResponseException.class org.apache.http.ParseException.class org.apache.http.ProtocolException.class org.apache.http.ProtocolVersion.class org.apache.http.ReasonPhraseCatalog.class org.apache.http.RequestLine.class org.apache.http.StatusLine.class org.apache.http.TokenIterator.class org.apache.http.TruncatedChunkException.class org.apache.http.UnsupportedHttpVersionException.class org.apache.http.annotation.Contract.class org.apache.http.annotation.Experimental.class org.apache.http.annotation.Obsolete.class org.apache.http.annotation.ThreadingBehavior.class org.apache.http.annotation.package-info.class org.apache.http.concurrent.BasicFuture.class org.apache.http.concurrent.Cancellable.class org.apache.http.concurrent.FutureCallback.class org.apache.http.concurrent.package-info.class org.apache.http.config.ConnectionConfig.class org.apache.http.config.Lookup.class org.apache.http.config.MessageConstraints.class org.apache.http.config.Registry.class org.apache.http.config.RegistryBuilder.class org.apache.http.config.SocketConfig.class org.apache.http.config.package-info.class org.apache.http.entity.AbstractHttpEntity.class org.apache.http.entity.BasicHttpEntity.class org.apache.http.entity.BufferedHttpEntity.class org.apache.http.entity.ByteArrayEntity.class org.apache.http.entity.ContentLengthStrategy.class org.apache.http.entity.ContentProducer.class org.apache.http.entity.ContentType.class org.apache.http.entity.EntityTemplate.class org.apache.http.entity.FileEntity.class org.apache.http.entity.HttpEntityWrapper.class org.apache.http.entity.InputStreamEntity.class org.apache.http.entity.SerializableEntity.class org.apache.http.entity.StringEntity.class org.apache.http.entity.package-info.class org.apache.http.impl.AbstractHttpClientConnection.class org.apache.http.impl.AbstractHttpServerConnection.class org.apache.http.impl.BHttpConnectionBase.class org.apache.http.impl.ConnSupport.class org.apache.http.impl.DefaultBHttpClientConnection.class org.apache.http.impl.DefaultBHttpClientConnectionFactory.class org.apache.http.impl.DefaultBHttpServerConnection.class org.apache.http.impl.DefaultBHttpServerConnectionFactory.class org.apache.http.impl.DefaultConnectionReuseStrategy.class org.apache.http.impl.DefaultHttpClientConnection.class org.apache.http.impl.DefaultHttpRequestFactory.class org.apache.http.impl.DefaultHttpResponseFactory.class org.apache.http.impl.DefaultHttpServerConnection.class org.apache.http.impl.EnglishReasonPhraseCatalog.class org.apache.http.impl.HttpConnectionMetricsImpl.class org.apache.http.impl.NoConnectionReuseStrategy.class org.apache.http.impl.SocketHttpClientConnection.class org.apache.http.impl.SocketHttpServerConnection.class org.apache.http.impl.bootstrap.HttpServer.class org.apache.http.impl.bootstrap.RequestListener.class org.apache.http.impl.bootstrap.SSLServerSetupHandler.class org.apache.http.impl.bootstrap.ServerBootstrap.class org.apache.http.impl.bootstrap.ThreadFactoryImpl.class