标签: http-status-code-404

404自定义重定向

您好我正在尝试重定向,如果响应是404,但它没有按预期工作,您可以专家看到问题吗?它仍然是通用的404

在我的Global.asax中

protected void Application_BeginRequest(Object sender, EventArgs e)
{
       if (Response.Status == "404 Not Found")
        {
            string notFound = "~/custom_notfound.aspx";
            Response.Redirect(notFound);
        } 

}
Run Code Online (Sandbox Code Playgroud)

UPDATE

到目前为止尝试过

(Response.Status == "404 Not Found")
(Response.Status == "404")
(Response.StatusCode == 404)
Run Code Online (Sandbox Code Playgroud)

c# asp.net redirect http-status-code-404

5
推荐指数
1
解决办法
5501
查看次数

MVC4 Custom 404页面?

我把它放在web.config中 <system.webServer>

<httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL">
    <remove statusCode="404" subStatusCode="-1" />
    <error statusCode="404" subStatusCode="-1" path="/cv/" responseMode="ExecuteURL" />
</httpErrors>
Run Code Online (Sandbox Code Playgroud)

临时使用的路径[myapplication]/cv /返回一个页面.

但是如果我去[myapplication]/[任何不存在的东西]来获得404响应,那么就没有任何反应.

这目前正在我的旧网站表单上工作,但我不能让它在MVC4网站上工作.我怎样才能做到这一点?(我不想使用"重定向/文件"方法)

web-config http-status-code-404 asp.net-mvc-4

5
推荐指数
1
解决办法
5247
查看次数

Spring mvc 3.1 tomcat 7 - 404不解析jsp但控制器注释工作正常

我已经在这方面工作了一段时间,根本不知道出了什么问题.我正在Tomcat 7上部署Spring 3.1 MVC应用程序.从查看DEBUG输出,我可以看到1)MVC调度程序servlet根据需要获取所有URL 2)映射到控制器注释的任何URL工作正常3)任何URL需要映射到JSP得到404.另外,我使用的是JDK 1.7.0_09.我的JSP页面位于/ WEB-INF/jsp /中.

提前感谢我可能缺少的任何提示!

这是我的web.xml:

    <?xml version="1.0" encoding="UTF-8"?>
<web-app 
    id="WebApp_ID" 
    version="2.5" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="
        http://java.sun.com/xml/ns/javaee 
        http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <display-name></display-name>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>
Run Code Online (Sandbox Code Playgroud)

我尝试将我的网址格式修改为/,/ ,/.,.到目前为止,"/"似乎占据了我最远的地步.此外,我可能是错的,但我不认为URL是问题,因为DEBUG日志显示所有的URL都转到调度程序servlet - 这就是我想要的.

这是我的dispatcher-servlet.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p" 
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.1.xsd
        http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">

    <!--Tell the servlet where to look for annotated methods-->
    <context:component-scan base-package="com.test.web.mvc.ctrl" />

    <!--Enables many annotations and searches for …
Run Code Online (Sandbox Code Playgroud)

java model-view-controller spring jsp http-status-code-404

5
推荐指数
1
解决办法
3510
查看次数

GlassFish 3.1.2给出404没有任何部署错误

我尝试将一个非常简单的helloworld.war部署到ubuntu 10.04上的glassfish 3.1.2服务器上.在我的电脑上它工作正常但在我的服务器上我总是得到404页面.我的服务器上没有错误.有人有想法吗?

我注意到另一种奇怪的行为 重启我的服务器后,我无法登录管理控制台.我总是认证失败重新输入您的用户名和密码.当我重新启动glassfish时,它再次起作用.

这听起来很熟悉,但我看不出他的解决方案如何帮助我. glassfish autodeploy为404提供简单的应用程序

[#|2012-12-14T02:53:30.368+0100|INFO|glassfish3.1.2|org.glassfish.admingui|_ThreadID=71;_ThreadName=Thread-2;|uploadFileName=HelloWorld-1.0-SNAPSHOT.war|#]

[#|2012-12-14T02:53:30.605+0100|INFO|glassfish3.1.2|javax.enterprise.resource.webcontainer.jsf.config|_ThreadID=135;_ThreadName=Thread-2;|Mojarra 2.1.6 (SNAPSHOT 20111206) für Kontext '/HelloWorld-1.0-SNAPSHOT' wird initialisiert.|#]

[#|2012-12-14T02:53:30.729+0100|INFO|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=135;_ThreadName=Thread-2;|WEB0671: Loading application [HelloWorld-1.0-SNAPSHOT] at [/HelloWorld-1.0-SNAPSHOT]|#]

[#|2012-12-14T02:53:30.883+0100|INFO|glassfish3.1.2|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=135;_ThreadName=Thread-2;|HelloWorld-1.0-SNAPSHOT was successfully deployed in 482 milliseconds.|#]
Run Code Online (Sandbox Code Playgroud)

的index.xhtml

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        Hello from Facelets
    </h:body>
</html>
Run Code Online (Sandbox Code Playgroud)

web.xml中

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name> …
Run Code Online (Sandbox Code Playgroud)

deployment glassfish war http-status-code-404

5
推荐指数
1
解决办法
2183
查看次数

尝试与我的自定义iOS应用分享Google+时出现404错误

我安装了适用于iOS的google + SDK并实现了共享功能:

- (void)customUIASView:(CustomUIASView *)customUIASView didClickGoogle:(UIButton *)sender{

    static NSString * const kClientId = @"122385832599-2mcvobo565un3ab7d6d06m6fjemocto9.apps.googleusercontent.com";
    share = [[GPPShare alloc] initWithClientID:kClientId];
    share.delegate = self;
    [[[[share shareDialog]
       setURLToShare:[NSURL URLWithString:myUrl]]
      setPrefillText:oPin.sName] open];

}
Run Code Online (Sandbox Code Playgroud)

一切正常,控制台没有错误,但是当使用此链接打开Safari手机时(适用于所有桌面浏览器),我收到404错误!

https://plus.google.com/share?client_id=122385832599-2mcvobo565un3ab7d6d06m6fjemocto9.apps.googleusercontent.com&continue=com.pinstyle.pinstyle%3A%2F%2Fshare%2F&text=NEU%20H%26M%20Divided%20Grey%20blogger% 20Trend%20urban%20Leder%20Biker%20Jacke%20Nieten%2034%20S%20XS%2036&URL = HTTP%3A%2F%2Fpinboard.maryme.lan.s3.amazonaws.com%2F1%2F25607-neuhmdividedgreybloggertrendurbanlederbikerjackenieten34sxs36.jpg&bundle_ID的= com.pinstyle. pinstyle&gpsdk = 1.0.0

有人有同样的错误:https://groups.google.com/forum/#! msg/google-plus-Developers/ZSCxGNTqRJY / jidPJ076BfYJ

但解决方案是将BundleID更改为另一个至少有一个点.我的bundleId已经有两个点,所以我不知道该怎么做.有没有人知道如何解决这个问题?谢谢!

share objective-c http-status-code-404 ios google-plus

5
推荐指数
1
解决办法
722
查看次数

404图像的后备

我每天都会使用PHP自动为联盟网站导入多个XML-feeds(Tradetracker,Daisycon等).饲料包含来自各种商店的产品.

除了图像外,一切都像魅力一样.Feed中的图像只是与提供商的图像热链接.这适用于大多数情况,但有时(由于各种原因)图像不再存在,受热链接保护,更改等等.这导致浏览器中"找不到图像",这不会好看.

我试图用htaccess来解决这个问题,但不管出于什么原因,它都行不通.我用谷歌搜索并尝试了几个htacces"脚本",但没有一个没有成功.我也在图片网址中尝试过JS,但这并不适用.我更喜欢htaccess.

有人有建议吗?

使用htaccess替换图像

RewriteEngine on
<FilesMatch ".(jpg|png|gif)$">
ErrorDocument 404 "/noimage.jpg"
</FilesMatch>
Run Code Online (Sandbox Code Playgroud)

使用JS

<img src="image.jpg" onerror="this.onerror=null;this.src='default.jpg'">
Run Code Online (Sandbox Code Playgroud)

更新:工作版

<script type="text/javascript"> 
   jQuery(window).load(function() { 
      jQuery("img").each(function(){ 
         var image = jQuery(this);             
         if(image.context.naturalWidth == 0 ||
         image.readyState == 'uninitialized'){    
            jQuery(image).unbind("error").attr(
                "src", "noimage.jpg"
            ); 
         } 
    }); 
}); 
</script>
Run Code Online (Sandbox Code Playgroud)

javascript .htaccess image http-status-code-404

5
推荐指数
1
解决办法
2242
查看次数

Laravel 4 - 使用自定义消息处理404s

根据Laravel 4 文档,我可以使用自定义响应抛出404:

App::abort(404, 'My Message');
Run Code Online (Sandbox Code Playgroud)

然后,我可以使用自定义页面处理所有404:

App::missing(function($exception)
{
    return Response::view('errors.missing', array(), 404);
});
Run Code Online (Sandbox Code Playgroud)

如何以与通用Laravel错误页面相同的方式将"我的消息"传递到视图.

谢谢!

php error-handling exception-handling http-status-code-404 laravel

5
推荐指数
2
解决办法
2070
查看次数

MVC 5 WebRequest URL中的尾随点导致404

我运行MVC 5,并有一个搜索API产生以下链接:/SearchedItem.?format=json这里SearchedItem.是用户输入的搜索.由于一个dot角色,这显然会导致着名的404 .我已经研究了以下所有解决方案:

点字符'.' 在MVC Web API 2中请求诸如api/people/STAFF.45287之类的请求

URL中的点导致404使用ASP.NET mvc和IIS

当ID包含句点时,ApiController返回404

然而,无论是加斜杠(尝试都/SearchedItem./?format=json和/SearchedItem.?format=json/),也不RAMMFAR工作.

寻找任何新的建议.

api url asp.net-mvc http-status-code-404

5
推荐指数
1
解决办法
578
查看次数

为什么POST请求返回404

我在PHP中有以下代码片段:

if (strcasecmp($_POST['method'], 'assignId') == 0) {
$username = $_POST['username'];

$response['code'] = 1;
$response['status'] = $api_response_code[$response['code']]['HTTP Response'];
$sql = "CALL new_person('$username')";

if (($result = $conn->query($sql)) === TRUE) {
    $row = $result->fetch_assoc();
    $response['data'] = $row;
}
deliver_response($response);
Run Code Online (Sandbox Code Playgroud)

new_person是一个存储过程,它返回一个id,它已经过测试,可以正常工作并deliver_response返回输入的JSON格式。它也已经过测试,可以正常工作。

为什么POST请求返回404错误?

存储过程正在执行,但不会返回结果。最后,当我将POST方法更改为GET并发出get请求时,它可以正常工作!

php http-post http-status-code-404

5
推荐指数
1
解决办法
6066
查看次数

WebRequest奇怪的NotFound错误

我有两个不同的ASP.NET核心网站:admin和public.两者都在登台服务器和本地计算机上运行.

我将GET请求发送到不同的页面以确定不同页面的执行时间并遇到管理站点的问题:本地实例上的所有URL和登台总是返回404错误:

System.dll中出现未处理的"System.Net.WebException"类型异常

附加信息:远程服务器返回错误:(404)Not Found.

同时,浏览器中的相同请求通常会返回html页面.通过HttpWebRequest公共站点的请求也始终返回200状态代码(OK).请求代码我在这里.

我试图从浏览器请求添加所有标头和cookie,但它没有帮助.还尝试调试本地实例,发现请求执行时没有抛出异常.

有任何想法吗?

c# webrequest httpwebrequest http-status-code-404 asp.net-core

5
推荐指数
1
解决办法
1171
查看次数