- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
用户将文本保存在包含单词“café”(注意“é”)的表单中。加载 #show
时显示此文本的页面,我得到一个 Encoding::CompatibilityError
留言incompatible character encodings: UTF-8 and ASCII-8BIT
.
错误可以在控制台中重复:
> r = Report.find(123) # load the record
> r.update(:comments => "café")
=> true
> r.comments
=> "caf\xC3\xA9"
> r.comments.encoding
=> #<Encoding:ASCII-8BIT>
> r.comments.encode("UTF-8")
Encoding::UndefinedConversionError: "\xC3" from ASCII-8BIT to UTF-8
from (irb):11:in `encode'
在 #show
上显示字段页面 ( <%= r.comments %>
) 产生错误。
编码不是 UTF-8,而是 ASCII-8BIT,这似乎是错误的,因为数据库列编码设置为 UTF-8,并且许多应用程序配置将编码定义为“UTF-8”。
理想情况下,“é”会按其输入的方式显示而不会出现任何错误,但在这一点上,我只想找到一种避免错误的方法。似乎我的所有表单(数十个)都容易受到此影响。
有没有办法让ASCII-8BIT字符显示出来?
强制编码 ( <%= string.force_encoding("UTF-8") %>
) 产生所需的结果,避免错误并正确显示字符,这导致了以下解决方法:
解决方法
# /config/initializers/active_record_extension_force_encode_read_attribute.rb
module ActiveRecordExtensionForceEncodeReadAttribute
def read_attribute(attr_name)
attribute = super
attribute.is_a?(String) ? attribute.force_encoding("UTF-8") : attribute
end
end
# include the extension
ActiveRecord::Base.send(:include, ActiveRecordExtensionForceEncodeReadAttribute)
出于多种原因,这感觉不对,但确实有效。
我的设置
我正在使用 mysql2
gem 。数据库列都是 UTF-8,TEXT 数据类型。我已经按照建议将 UTF-8 声明为我的应用程序的编码(通过 How to fix ActionView::Template::Error (incompatible character encodings: ASCII-8BIT and UTF-8) )。
参数看起来像这样
Parameters: {"utf8"=>"✓", "authenticity_token"=>"my_auth_token=", "commit"=>"Save", "report"=>{"comments"=>"café "}}
错误是Encoding::CompatibilityError in WeekendManagerReports#show
( View )与消息:incompatible character encodings: UTF-8 and ASCII-8BIT
并在我打印属性的 View 中被标记:
<%= @report.comments %>
错误堆栈跟踪:
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/core_ext/string/output_safety.rb:180:in `concat'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/core_ext/string/output_safety.rb:180:in `concat'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/buffers.rb:12:in `<<'
app/views/weekend_manager_reports/_show_fields.html.erb:68:in `_app_views_weekend_manager_reports__show_fields_html_erb___2906173005587511585_48245020'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/template.rb:145:in `block in render'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/notifications.rb:161:in `instrument'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/template.rb:339:in `instrument'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/template.rb:143:in `render'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/renderer/partial_renderer.rb:306:in `render_partial'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/renderer/partial_renderer.rb:279:in `block in render'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/notifications.rb:159:in `block in instrument'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/notifications.rb:159:in `instrument'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/renderer/partial_renderer.rb:278:in `render'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/renderer/renderer.rb:47:in `render_partial'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/helpers/rendering_helper.rb:35:in `render'
app/views/weekend_manager_reports/_show.html.erb:1:in `_app_views_weekend_manager_reports__show_html_erb__1009321416738415989_48308580'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/template.rb:145:in `block in render'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/notifications.rb:161:in `instrument'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/template.rb:339:in `instrument'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/template.rb:143:in `render'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/renderer/partial_renderer.rb:306:in `render_partial'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/renderer/partial_renderer.rb:279:in `block in render'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/notifications.rb:159:in `block in instrument'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/notifications.rb:159:in `instrument'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/renderer/partial_renderer.rb:278:in `render'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/renderer/renderer.rb:47:in `render_partial'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/helpers/rendering_helper.rb:35:in `render'
app/views/reports/show.html.erb:56:in `_app_views_reports_show_html_erb__2577918850424361413_47390860'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/template.rb:145:in `block in render'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/notifications.rb:161:in `instrument'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/template.rb:339:in `instrument'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/template.rb:143:in `render'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/renderer/template_renderer.rb:55:in `block (2 levels) in render_template'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/notifications.rb:159:in `block in instrument'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/notifications.rb:159:in `instrument'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/renderer/template_renderer.rb:54:in `block in render_template'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/renderer/template_renderer.rb:62:in `render_with_layout'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/renderer/template_renderer.rb:53:in `render_template'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/renderer/template_renderer.rb:17:in `render'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/renderer/renderer.rb:42:in `render_template'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/renderer/renderer.rb:23:in `render'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/rendering.rb:99:in `_render_template'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_controller/metal/streaming.rb:217:in `_render_template'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/rendering.rb:82:in `render_to_body'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_controller/metal/rendering.rb:32:in `render_to_body'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_controller/metal/renderers.rb:32:in `render_to_body'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/abstract_controller/rendering.rb:25:in `render'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_controller/metal/rendering.rb:16:in `render'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/home/vhc3248/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/benchmark.rb:303:in `realtime'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/core_ext/benchmark.rb:12:in `ms'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_controller/metal/instrumentation.rb:41:in `block in render'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.9/lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_controller/metal/instrumentation.rb:40:in `render'
vendor/bundle/ruby/2.2.0/bundler/gems/wicked_pdf-8f970f29c4de/lib/wicked_pdf/pdf_helper.rb:22:in `render_with_wicked_pdf'
app/controllers/concerns/common_report_controller_functions.rb:88:in `block (2 levels) in show'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_controller/metal/mime_responds.rb:258:in `call'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_controller/metal/mime_responds.rb:258:in `respond_to'
app/controllers/concerns/common_report_controller_functions.rb:86:in `show'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/abstract_controller/base.rb:189:in `process_action'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_controller/metal/rendering.rb:10:in `process_action'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:113:in `call'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:113:in `call'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:149:in `call'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:149:in `call'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:149:in `call'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:229:in `call'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:229:in `block in halting'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:166:in `call'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:166:in `block in halting'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:166:in `call'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:166:in `block in halting'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:149:in `call'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:229:in `call'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:229:in `block in halting'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:166:in `call'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:166:in `block in halting'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:166:in `call'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:166:in `block in halting'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:86:in `call'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:86:in `run_callbacks'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/abstract_controller/callbacks.rb:19:in `process_action'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_controller/metal/rescue.rb:29:in `process_action'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/notifications.rb:159:in `block in instrument'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/notifications.rb:159:in `instrument'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.9/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/abstract_controller/base.rb:136:in `process'
vendor/bundle/ruby/2.2.0/gems/actionview-4.1.9/lib/action_view/rendering.rb:30:in `process'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_controller/metal.rb:196:in `dispatch'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_controller/metal.rb:232:in `block in action'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_dispatch/routing/route_set.rb:82:in `call'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_dispatch/routing/route_set.rb:50:in `call'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_dispatch/journey/router.rb:73:in `block in call'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_dispatch/journey/router.rb:59:in `each'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_dispatch/journey/router.rb:59:in `call'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_dispatch/routing/route_set.rb:685:in `call'
vendor/bundle/ruby/2.2.0/gems/exception_notification-4.0.1/lib/exception_notification/rack.rb:28:in `call'
vendor/bundle/ruby/2.2.0/gems/warden-1.2.3/lib/warden/manager.rb:35:in `block in call'
vendor/bundle/ruby/2.2.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `catch'
vendor/bundle/ruby/2.2.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `call'
vendor/bundle/ruby/2.2.0/gems/rack-1.5.5/lib/rack/etag.rb:23:in `call'
vendor/bundle/ruby/2.2.0/gems/rack-1.5.5/lib/rack/conditionalget.rb:25:in `call'
vendor/bundle/ruby/2.2.0/gems/rack-1.5.5/lib/rack/head.rb:11:in `call'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_dispatch/middleware/flash.rb:254:in `call'
vendor/bundle/ruby/2.2.0/gems/rack-1.5.5/lib/rack/session/abstract/id.rb:225:in `context'
vendor/bundle/ruby/2.2.0/gems/rack-1.5.5/lib/rack/session/abstract/id.rb:220:in `call'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_dispatch/middleware/cookies.rb:562:in `call'
vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.9/lib/active_record/query_cache.rb:36:in `call'
vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb:82:in `run_callbacks'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
vendor/bundle/ruby/2.2.0/gems/railties-4.1.9/lib/rails/rack/logger.rb:38:in `call_app'
vendor/bundle/ruby/2.2.0/gems/railties-4.1.9/lib/rails/rack/logger.rb:22:in `call'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_dispatch/middleware/request_id.rb:21:in `call'
vendor/bundle/ruby/2.2.0/gems/rack-1.5.5/lib/rack/methodoverride.rb:21:in `call'
vendor/bundle/ruby/2.2.0/gems/rack-1.5.5/lib/rack/runtime.rb:17:in `call'
vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.9/lib/action_dispatch/middleware/static.rb:84:in `call'
vendor/bundle/ruby/2.2.0/gems/rack-1.5.5/lib/rack/sendfile.rb:112:in `call'
vendor/bundle/ruby/2.2.0/gems/railties-4.1.9/lib/rails/engine.rb:514:in `call'
vendor/bundle/ruby/2.2.0/gems/railties-4.1.9/lib/rails/application.rb:144:in `call'
最佳答案
您可以在 show
页面上显示文本:
<%= string.force_encoding('UTF-8') %>
关于mysql - 显示用户输入的 ASCII-8BIT 字符时出现 "incompatible character encodings: UTF-8 and ASCII-8BIT"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42078430/
我的应用程序从一个有 5 个选项卡的选项卡栏 Controller 开始。一开始,第一个出现了它的名字,但其他四个没有名字,直到我点击它们。然后根据用户使用的语言显示名称。如何在选项卡栏出现之前设置选
我有嵌套数组 json 对象(第 1 层、第 2 层和第 3 层)。我的问题是数据表没有出现。任何相关的 CDN 均已导入。该表仅显示部分。我引用了很多网站,但都没有解决我的问题。 之前我使用标准表来
我正在尝试设置要显示的 Parse PFLoginViewController。这是我的一个 View Controller 的类。 import UIKit import Parse import
我遇到了这个问题,我绘制的对象没有出现在 GUI 中。我知道它正在被处理,因为数据被推送到日志文件。但是,图形没有出现。 这是我的一些代码: public static void main(Strin
我有一个树状图,其中包含出现这样的词...... TreeMap occurrence = new TreeMap (); 字符串 = 单词 整数 = 出现次数。 我如何获得最大出现次数 - 整数,
因此,我提示用户输入变量。如果变量小于 0 且大于 10。如果用户输入 10,我想要求用户再次输入数字。我问时间的时候输入4,它说你输入错误。但在第二次尝试时效果很好。例如:如果我输入 25,它会打印
我已经用 css overflow 属性做了一个例子。在这个例子中我遇到了一个溢出滚动的问题。滚动条出现了,但没有工作意味着每当将光标移动到滚动条时,在这个滚动条不活动的时间。我对此一无所知,所以请帮
我现在正在做一个元素。当您单击一个元素时,会出现以下信息,我想知道如何在您单击下一个元素而不重新单击同一元素时使其消失....例如,我的元素中有披萨,我想单击肉披萨看到浇头然后点击奶酪披萨看到浇头和肉
我有一个路由器模块,它将主题与正则表达式进行比较,并将出现的事件与一致的键掩码链接起来。 (它是一个简单的 url 路由过滤,如 symfony http://symfony.com/doc/curr
这个问题在这里已经有了答案: 9年前关闭。 Possible Duplicate: mysql_fetch_array() expects parameter 1 to be resource, bo
我在底部有一个带有工具栏的 View ,我正在使用 NavigationLink 导航到该 View 。但是当 View 出现时,工具栏显示得有点太低了。大约半秒钟后,它突然跳到位。它只会在应用程序启
我试图在我的应用程序上为背景音乐添加一个 AVAudioPlayer,我正在主屏幕上启动播放器,尝试在应用程序打开时开始播放但出现意外行为... 它播放并立即不断创建新玩家并播放这些玩家,因此同时播放
这是获取一个数字,获取其阶乘并将其加倍,但是由于基本情况,如果您输入 0,它会给出 2 作为答案,因此为了绕过它,我使用了 if 语句,但收到错误输入“if”时解析错误。如果你们能提供帮助,我真的很感
暂停期间抛出异常 android.os.DeadObjectException 在 android.os.BinderProxy.transactNative( native 方法) 在 androi
我已经为猜词游戏编写了一些代码。它从用户输入中读取字符并在单词中搜索该字符;根据字符是否在单词中,程序返回并控制一些变量。 代码如下: import java.util.Random; import
我是自动化领域的新手。这是我的简单 TestNG 登录代码,当我以 TestNG 身份运行该代码时,它会出现 java.lang.NullPointerException,双击它会突出显示我导航到 U
我是c#程序员,我习惯了c#的封装语法和其他东西。但是现在,由于某些原因,我应该用java写一些东西,我现在正在练习java一天!我要创建一个为我自己创建一个虚拟项目,以便让自己更熟悉 Java 的
我正在使用 Intellij,我的源类是 main.com.coding,我的资源文件是 main.com.testing。我将 spring.xml 文件放入资源文件中。 我的测试类位于 test.
我想要我的tests folder separate到我的应用程序代码。我的项目结构是这样的 myproject/ myproject/ myproject.py moduleon
这个问题已经有答案了: What is a NullPointerException, and how do I fix it? (12 个回答) 已关闭 6 年前。 因此,我尝试比较 2 个值,一个
我是一名优秀的程序员,十分优秀!