EasyUI初步使用课题的展示(第六天)

第六天;

构思:
1.在struts.xml里面的action通过type="redirectAction"直接在struts.xml里面跳转到另外一个action,然后执行
2.自动查询所有科目
3.根据放进Session的userinfo去 ErrorsubjectDAO里面找到错题信息

我们需要知道

  • El表达式
  • ognl表达式

今天我们要完成的样式如下图


EasyUI初步使用课题的展示(第六天)_第1张图片
image.png

这是EasyUI其中的一个框架,贴上代码

onepage.jsp

 <%@ page language="java" import="java.util.* " pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>






My JSP 'MyJsp.jsp' starting page








  






        
        
        
道) '" style="width:16%;padding:10px;">
编    号 ${s.count }
科    目 ${v.subject.allclass.classname }
错误次数 ${v.errordegree }
错误时间 ${v.errordate }
  查    看    详    情

Copyright@2016-2017 浙ICP备160465465号-1

    

提供对题库的搜索

同时我们也配套添加了一个jsp

nav.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>



  
    
    
    My JSP 'xxJsp.jsp' starting page
    
    
    
        
    
    
    

  
  
  
        
  

有了新需求,自然配置文件也会随之变动

struts.xml

    
       
                answerview
                /error.jsp
        
        
                 /userinfo/register.jsp
        
        
                 /index.jsp
             
        
        
           /homepage/onepage.jsp
        
    

struts.xml对应的·java文件也发生变化

AllclassAction.java

package com.jianshu.action;

import java.util.List;

import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;

import com.jianshu.bean.Userinfo;
import com.jianshu.service.AllclassService;
import com.jianshu.service.ErrorsubjectService;

public class AllclassAction {
    @Autowired
    AllclassService allclassService;
    @Autowired
    ErrorsubjectService errorsubjectService;
    
    List allErrorsubject;
    public List getAllErrorsubject() {
        return allErrorsubject;
    }
    public void setAllErrorsubject(List allErrorsubject) {
        this.allErrorsubject = allErrorsubject;
    }
    List allclassList;
    public List getAllclassList() {
        return allclassList;
    }
    public void setAllclassList(List allclassList) {
        this.allclassList = allclassList;
    }
    /**
     * 查询所有科目,和错题
     * @return success
     */
    public String classList() {
        allclassList = allclassService.findAll();
         Userinfo userinfo = (Userinfo) ServletActionContext.getRequest()
                    .getSession().getAttribute("userinfo");// 从session里面取出userinfo
        allErrorsubject = errorsubjectService.findList(userinfo);
        return "success";
    }
}

AllclassService.java

package com.jianshu.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.jianshu.dao.AllclassDAO;

public class AllclassService {
    @Autowired
    AllclassDAO allclassDAO;
    public AllclassDAO getAllclassDAO() {
        return allclassDAO;
    }
    public void setAllclassDAO(AllclassDAO allclassDAO) {
        this.allclassDAO = allclassDAO;
    }
    /**
     * 查詢到所有科目
     * @return
     */
    public List findAll() {
        // TODO Auto-generated method stub
        return allclassDAO.findAll();
    }

}

ErrorsubjectService

package com.jianshu.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.jianshu.bean.Userinfo;
import com.jianshu.dao.ErrorsubjectDAO;

public class ErrorsubjectService {
    @Autowired
    ErrorsubjectDAO errorsubjectDAO;
    /**
     * 根据用户id查询
     * @param userinfo
     * @return
     */
    public List findList(Userinfo userinfo) {
        return errorsubjectDAO.findByUserid(userinfo.getUserid());
    }
}

ErrorsubjectDAO要添加

    public static final String USERID = "userinfo.userid";
    /**'
     * 执行hql
     * @param userid
     * @return
     */
    public List findByUserid(Long userid) {
        return findByProperty(USERID, userid);
    }

你可能感兴趣的:(EasyUI初步使用课题的展示(第六天))