作业二
在miaosha包下新建config、exception、valodator的包。
config包下新建class名为UserArgumentResolver、WebConfig。UserArgumentResolver中使用resolveArgument()方法确认错误,WebConfig中编写addArgumentResolvers()方法。
在contorller包下创建class名为GoodsController、LoginController。GoodsController中使用list()方法,跳转到列表清单list页面。LoginController中编写deLogin()方法,若无问题则返回true。
exception包下创建class名为GlobalException、GlobalExceptionHandler。 GlobalException要extends RuntimeException,并在里面编写getSerialVersionUID()方法返回serialVersionUID。GlobalExceptionHandler中需要判断定义的Exception e是否为空,空、错误等等,分别返回BIND_ERROR、SERVER_ERROR。
valodator包下创建class名为IsMobileValidator,implements ConstraintValidator,编写isValid()方法判断reqired。创建IsMobile类,类型为@interface,编写ture和“手机号码格式错误”等。
在templates包下新建goods_list.html,用于编写页面。
作业二
最新推荐文章于 2023-12-21 11:25:51 发布