我正在尝试设置自定义404错误页面。在我的web.config中,我在system.web
中有这个<customErrors mode="RemoteOnly">
<error statusCode="404" redirect="~/Home/Error404" />
</customErrors>
我的HomeController中有这个方法
public ActionResult Error404()
{
return View();
}
和我的观点
@{
ViewBag.Title = "Error404";
}
<h2>Error404</h2>
我的问题是,当我转到我网站中不存在的网址时,我没有获得自定义网页。有什么我想念的吗?
答案 0 :(得分:4)
代码中未为本地启用自定义错误页面。所以,如果你在本地测试它,它将无法工作。如下所示更改web.config条目以在本地启用自定义错误页面
package Chapter7;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;
import java.util.concurrent.RecursiveAction;
import java.util.concurrent.atomic.AtomicInteger;
@SuppressWarnings("serial")
public class PrcForkJoinTask extends RecursiveAction {
private int start , end;
AtomicInteger count = new AtomicInteger(0);
public PrcForkJoinTask(int start, int end){
this.start = start;
this.end = end;
}
@Override
protected void compute() {
// TODO Auto-generated method stub
if(end - start <= 2 ){
System.out.println("close condition reached" + "Start is " + start + "end is " + end) ;
System.out.println("calculated times" + count.getAndIncrement());
}
else{
int middle = start + ((end - start) / 2);
System.out.println("middle is " + middle) ;
invokeAll( new PrcForkJoinTask(start,middle),new PrcForkJoinTask(middle,end));
}
}
public static void main(String[] args){
ForkJoinTask<?> fs = new PrcForkJoinTask(0,10);
ForkJoinPool pool = new ForkJoinPool();
pool.invoke(fs);
}
}