如果我尝试访问我的rails应用程序的URL中的一些随机字符串,比如/asdfasdifjasdfkj那时我看到一个rails错误消息
路由错误
No route matches "/asdfasdifjasdfkj" with {:method=>:get}
即使我处于生产模式.显然,我不希望任何真正的用户看到这一点,并且更喜欢404页面.任何人都知道什么是错的以及我如何解决它?
在我的网络配置中,我有:
<customErrors mode="On">
<error statusCode="404" redirect="~/error/404.aspx" />
</customErrors>
Run Code Online (Sandbox Code Playgroud)
http:// localhost / meh <-显示标准404
http://localhost/meh.aspx <-显示自定义404
http://localhost/error/404.aspx <-我要针对所有 404错误显示的自定义错误页面
如何设置我的web.config以将所有404发送到我的自定义错误?
谢谢
我正在支持一个magento网站.问题是产品视图网址例如[link] http:// localhost/magento/catalog/product/view/id/23总是返回404.
类别视图URL例如[link] http:// localhost/magento/catalog/category/view/id/4工作正常.
我应该在代码中调查一下吗?还是在数据库中?
谢谢
IIS具有可配置的阈值,用于过滤出“过大”的请求,因此有可能对服务器进行DoS。这样的请求产生代码404.13。但是HTTP的代码413 Request Entity Too Large看起来恰好适合这种情况。
为什么返回代码404而不是代码413?
所以,在我的项目中,我想添加一个自定义的404错误页面,所以我按照我在网上找到的内容,但似乎没有什么对我有用.
这就是我的文件:
settings.py
import os
# Django settings for HogwartsMail project.
PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
DEBUG = False
TEMPLATE_DEBUG = DEBUG
# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ["*"]
Run Code Online (Sandbox Code Playgroud)
urls.py
urlpatterns = patterns('',
...
)
handler404 = "HogwartsMail.views.error404"
Run Code Online (Sandbox Code Playgroud)
views.py
def error404(request):
return render(request,'404.html')
Run Code Online (Sandbox Code Playgroud)
每当我尝试输入一个随机网址时,我得到的服务器错误(500)并没有得到404错误.
正如我所说,我尝试了许多不同的方式,但没有一个真正适合我.
另外,我遇到的另一个问题是我加载的页面非常慢,并且它们没有打开样式或图像,所以我认为,当DEBUG = False我需要一切已经在线时.那是对的吗?
我在这上面尝试过很多网址,看起来很好,直到我遇到这个特定的网址:
require 'rubygems'
require 'nokogiri'
require 'open-uri'
doc = Nokogiri::HTML(open("http://www.moxyst.com/fashion/men-clothing/underwear.html"))
puts doc
Run Code Online (Sandbox Code Playgroud)
这是结果:
/Users/macbookair/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/open-uri.rb:353:in `open_http': 404 Not Found (OpenURI::HTTPError)
from /Users/macbookair/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/open-uri.rb:709:in `buffer_open'
from /Users/macbookair/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/open-uri.rb:210:in `block in open_loop'
from /Users/macbookair/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/open-uri.rb:208:in `catch'
from /Users/macbookair/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/open-uri.rb:208:in `open_loop'
from /Users/macbookair/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/open-uri.rb:149:in `open_uri'
from /Users/macbookair/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/open-uri.rb:689:in `open'
from /Users/macbookair/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/open-uri.rb:34:in `open'
from test.rb:5:in `<main>'
Run Code Online (Sandbox Code Playgroud)
我可以从网络浏览器访问它,我根本就没有得到它.
发生了什么,我该如何处理这种错误?我可以忽略它,让其余的工作吗?
我试图找出控制基本Spring Boot RESTful服务的404 Not Found处理程序的最简单方法,例如Spring提供的示例:
https://spring.io/guides/gs/rest-service/
而不是让它返回默认的Json输出:
{
"timestamp":1432047177086,
"status":404,
"error":"Not Found",
"exception":"org.springframework.web.servlet.NoHandlerFoundException",
"message":"No handler found for GET /aaa, ..."
}
Run Code Online (Sandbox Code Playgroud)
我想提供自己的Json输出。
通过控制DispatcherServlet和使用DispatcherServlet#setThrowExceptionIfNoHandlerFound(true),我能够使它在404的情况下引发异常,但是我无法通过来处理该异常@ExceptionHandler,就像我处理一样MissingServletRequestParameterException。知道为什么吗?
还是有比抛出并处理NoHandlerFoundException更好的方法?
我的Tomcat status code 404上部署的每个应用程序都会在我发出的每个请求中返回 我尝试过几个项目,helloworlds或者骷髅,每个项目的行为与其他项目相同:
我用过的一些项目:
https://github.com/mwarman/skeleton-ws-spring-boot
https://spring.io/guides/gs/rest-service/(我可以运行它,mvn spring-boot:run但它不能部署到Tomcat)
https://github.com/shagstrom/spring-mvc-hibernate-skeleton
我正在使用最新的Tomcat8 (8.0.27),Oracle JDK 8.我也试过Tomcat7了OpenJDK 7.使用的Tomcats在MAC和Debian上运行.我通过mvn和Intellij Idea构建应用程序.
Tomcats很干净,没有更改配置(除了添加manager-gui用户).
由于我尝试了很多不同的项目,我不相信代码中存在问题.它是在Tomcat的配置中吗?我怎样才能让它发挥作用?
编辑:
server.xml代码:
<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" …Run Code Online (Sandbox Code Playgroud) 我尝试安装Ruby时遇到此错误.我试过看这个和这个,但无济于事
? ~ brew install ruby
Warning: You are using OS X 10.12.
We do not provide support for this pre-release version.
You may encounter build failures or other breakages.
Please create pull-requests instead of filing issues.
==> Installing dependencies for ruby: readline, libyaml, makedepend
==> Installing ruby dependency: readline
==> Downloading https://ftpmirror.gnu.org/readline/readline-6.3.tar.gz
==> Downloading from http://mirror.team-cymru.org/gnu/readline/readline-6.3.tar.gz
######################################################################## 100.0%
==> Downloading https://gist.githubusercontent.com/jacknagel/d886531fb6623b60b2af/
curl: (22) The requested URL returned error: 404 Not Found
Error: Failed to download …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的网站中为“找不到页面”添加自定义404错误页面或输入错误的URL。我有app.yaml文件,并使用过Go语言。我的网站基本上位于Google App Engine中。我检查了每个我认为与我的堆栈溢出问题有关的示例。但是在某些示例中,他们用Python或Java语言解释了示例,但我想用Go语言查找。因为我的代码是用Go编写的。
静态错误404页面已加载到服务器中,但是当我输入错误的URL时,它将显示未找到错误页面而不是我的自定义页面。我已附上截图,它告诉了您一切。
当前:-https : //imgur.com/a/sGrSPyO “这是当前显示的内容”
必需:-https: //imgur.com/a/TxL7NMR “这就是我想要的”
我已经阅读了Google App Engine的app.yaml文档,并尝试放置错误处理程序,但是我没有找到任何解决方案。
app.yaml文件代码
runtime: go
api_version: go1
handlers:
-url: /
static_files: www/index.html
upload: www/index.html
-url: /(.*)
static_files: www/\1
upload: www/(.*)
error_handlers:
-file: www/page-not-found.html*
Run Code Online (Sandbox Code Playgroud)
这是更新的app.yaml文件:
runtime: go
api_version: go1
error_handlers:
- file: /page-not-found.html
handlers:
- url: /
static_files: www/index.html
upload: www/index.html
- url: /(.*)
static_files: www/\1
upload: www/(.*)
Run Code Online (Sandbox Code Playgroud) google-app-engine custom-error-pages go vs-web-site-project http-status-code-404