首页 > 代码库 > dwr异常处理
dwr异常处理
配置异常转换器:
dwr.xml:
<!-- 异常转换 --> <convert match="java.lang.Exception" converter="exception"/> <convert match="java.lang.StackTraceElement" converter="bean"/>
UserService:
delete.jsppackage com.demo.service; import java.util.ArrayList; import java.util.List; import com.demo.model.User; public class UserService { public static final String SUCCESS="success"; public String add(User user){ System.out.println(user); return SUCCESS; } public String deleted(int userId){ throw new RuntimeException("删除出错了..."); } public String update(User user){ System.out.println("update:"+user); return SUCCESS; } public List<User> list(){ List<User> users=new ArrayList<User>(); users.add(new User(1,"aa")); users.add(new User(2,"bb")); users.add(new User(3,"cc")); return users; } }
结果:<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>user delete</title> <script type="text/javascript" src=http://www.mamicode.com/"/dwr/engine.js"></script>>
dwr异常处理
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。