发表于: 2017-07-04 21:57:32
1 1069
今天完成的:
Task4的任务1还没有完成
遇到的问题:
做Task4没有沿用以前的项目,重新搭建了SSM框架,线下的第一天什么都没干,光debug了
1.静态页面放在WEB-INF下,无法被访问到,无论怎么该路径都没法访问,很诡异。最后只好把资源放到webapp下。如果使用springMVC的话静态资源会被filter过滤,需要配置静态资源映射。但我还没配springMVC就出了这个问题,最后也没解决。
2.注解service出错,提示No qualifying bean of type [com.jnshu.service.ServiceInterface] found for dependency。一般这个问题是有于无法实例化bean,没有配置service扫描包,没有正确注解service实现类或没有配置MVC的注解驱动导致。但我的根本没有这些问题,之前的项目,同样的ssm配置就能运行。
收获:
设计了Task4的db,将静态页面中的学生人数和就业人数改成了DB查询出的动态显示,但由于以上问题的原因跑不起来。
dao
@Repository
public interface StudentDAO {
int countStudent();
}
service
@Service
public class ServiceTest implements ServiceInterface{
public int countService(){
ApplicationContext x = new ClassPathXmlApplicationContext("spring-dao.xml");
StudentDAO s =(StudentDAO) x.getBean("StudentDAO");
return s.countStudent();
}
controller
@Controller
@RequestMapping(value = "/page",method = RequestMethod.GET)
public class controller extends HttpServlet{
@Autowired
ServiceInterface ser;
@RequestMapping(value = "/count",method = RequestMethod.GET)
public void countController(HttpServletRequest request){
int num=ser.countService();
System.out.println("---------------------------------------------");
request.setAttribute("count",num);
request.getRequestDispatcher("/WEB-INF/test.jsp");
}
}
明天的计划:
加快进度做Task4,今天把精力都放到debug上了,效率太低。
评论