发表于: 2017-06-20 18:03:21
1 1024
今天完成的事:
今天通过多次运行程序来感受service和web端分离后的情况,下面是web端的部分代码:
try {
switch (flag) {
case 1:
StudentService studentService1 = (StudentService) context.getBean("studentService1");
System.out.println("第一层访问service1");
student = studentService1.select(id);
break;
default:
StudentService studentService2 = (StudentService) context.getBean("studentService2");
System.out.println("第一层访问service2");
student = studentService2.select(id);
break;
}
} catch (Exception e1) {
switch (flag) {
case 1:
StudentService studentService2 = (StudentService) context.getBean("studentService2");
System.out.println("第一层访问失败,转为第二层访问service2");
student = studentService2.select(id);
break;
default:
StudentService studentService1 = (StudentService) context.getBean("studentService1");
System.out.println("第一层访问失败,转为第二层访问service1");
student = studentService1.select(id);
break;
}
}
多次运行的情况下,“第一层访问service1” 、“第一层访问失败,转为访问第二层service1”都有出现(看着像是随机的)。
因为遇到了页面战士的问题,又把jsp看了下,
taglib指令语法:
<%@ taglib uri="uri" prefix="prefixOfTag" %>
其中uri是自定义标签的地址,prefix是前缀。如果我没理解的错的话,应该是下面这样的对应关系。
明日计划:
开始任务9
遇到的问题:
1,虽然service1和2都发布成功了,但是用Tomcat跑项目失败,看了师兄的日报发现,需要先把service发布,然后再用Tomcat跑项目,试了下,成功了。
(这个是师兄的代码运行成功了)
(这个是我的代码运行成功了一半)
目前看程序的流程是跑通了,但是在页面展示时出错了,原因是json-taglib-0.4.1.jar这个包通过pom.xml配置的方式失败,然后转向直接把jar包导入的方式在打包后也没有打进去。尝试用maven命令把jar包放进本地仓库也失败了。。。
收获:
评论