NutzCN Logo
问答 关于fail注解使用,求解
发布于 2540天前 作者 kamier 2883 次浏览 复制 上一个帖子 下一个帖子
标签:
	/*删除成员*/
	@At("/delete")
	@Fail("jsp:/jsp/500.html")//我想让其发生异常后跳到这个500.html的页面   500.HTML在项目的web-inf下jsp文件夹下
	public Object delete(String name) throws Exception {
			name=null;//故意让其异常
			String name1=new String(name.getBytes("iso-8859-1"),"UTF-8");
			String[] names=name1.split(",");//字符串拆分
			for (int i = 0; i < names.length; i++){
			    dao.delete(Member.class, names[i]);  //根据name逐一删除数据
			}			
			     
			List<Member> list= dao.query(Member.class, null);
			return new Responze("删除成功!!",list);
 
    }
8 回复
@Fail("jsp:/WEB-INF/jsp/500.html")

  For example:> "SELECT * FROM t_member  WHERE LOWER(name) LIKE LOWER('%%')"
2018-01-08 12:36:58,030 org.nutz.mvc.impl.UrlMappingImpl.get(UrlMappingImpl.java:101) DEBUG - Found mapping for [GET] path=/member/delete : MemberModule.delete(MemberModule.java:42)
2018-01-08 12:36:58,030 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:151) DEBUG - Get 'memberModule'<class net.wendal.nutzbook.module.MemberModule>
2018-01-08 12:36:58,033 org.nutz.mvc.impl.processor.FailProcessor.process(FailProcessor.java:28) WARN  - Error@/member/delete :
java.lang.NullPointerException
	at net.wendal.nutzbook.module.MemberModule.delete(MemberModule.java:43)
	at net.wendal.nutzbook.module.MemberModule$$FASTCLASS._invoke(MemberModule.java:1)
	at org.nutz.lang.reflect.AbstractFastClass.invoke(AbstractFastClass.java:143)
	at org.nutz.lang.reflect.FastClassFactory.invoke(FastClassFactory.java:67)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:198)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)

没有按照预期跳转到500.jsp中 是不是我的配置有问题

这是web.xml中的配置

    <error-page>
        <error-code>500</error-code>
        <location>/WEB-INF/jsp/500.jsp</location>
    </error-page>

这个fail只要配置在入口函数处就行吗@wendal

页面提示404?

点删除的时候 后台报异常,页面没有任何反应

    function user_delete(userId) {
        var s = prompt("请输入y确认删除");
        if (s == "y") {
            $.ajax({
                url : base + "/user/delete",
                data : {"id":userId},
                dataType : "json",
                success : function (data) {
                    if (data.ok) {
                        user_reload();
                        alert("删除成功");
                    } else {
                        alert(data.msg);
                    }
                }
            });
        }
    };

对ajax请求

你觉得返回jsp页面的时候,内容就不是json,还能进success吗?

ajax会自己发现那是个页面,然后替换当前显示吗? 不会的

添加回复
请先登陆
回到顶部