资源简介

用ssh实现的在线考试系统,内附详细说明,包括表结构,和Oracle数据库导入文件,powerdsigner数据库pdm设计文件,可以根据pdm文件生成你自己相应数据库的表生成文件。 系统实现:用户填写个人信息,进入考试随机生成20(可修改)道单选,20道多选题目,提交后自动记分,并显示排名。

资源截图

代码片段和文件信息

package com.xl.exam.action;

import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.StrutsStatics;
 
import com.xl.exam.dto.UserDTO;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

/**
 * 公共Action
 * 
 * @author: louzi
 * @Date: 2018.05.02
 */
public class baseAction extends ActionSupport {
public List validList;
/**
 * 序列號
 */
private static final long serialVersionUID = 1L;

/**
 * 獲得sesstion
 * 
 * @return
 */
public Mapject> getSession() {
Mapject> session = ActionContext.getContext().getSession();
return session;
}

/**
 * 獲得request
 */
public static HttpServletRequest getRequest() {
ActionContext ctx = ActionContext.getContext();
HttpServletRequest request = (HttpServletRequest) ctx.get(StrutsStatics.HTTP_REQUEST);
return request;
}

/**
 * 獲得response
 */
public static HttpServletResponse getResponse() {
ActionContext ctx = ActionContext.getContext();
HttpServletResponse response = (HttpServletResponse) ctx.get(StrutsStatics.HTTP_RESPONSE);
return response;
}

/**
 * 從sesstion獲得當前登錄用戶
 * 
 * @return
 */
public UserDTO getUser() {
UserDTO userDTO = null;
if (getSession().get(“userSession“) != null) {
userDTO = (UserDTO) getSession().get(“userSession“);
}
return userDTO;
}

public static String getUserIp() {
  String ipFromNginx = getHeader(getRequest() “X-Real-IP“);
  return StringUtils.isEmpty(ipFromNginx) ? getRequest().getRemoteAddr() : ipFromNginx;
 }


private static String getHeader(HttpServletRequest request String headName) {
String value = request.getHeader(headName);
return !StringUtils.isBlank(value)
&& !“unknown“.equalsIgnoreCase(value) ? value : ““;
}


public static String getLoalhostIP(){
     String ip1 = ““;
     try {
        
            Enumeration enumeration=NetworkInterface.getNetworkInterfaces();
            InetAddress ip=null;
            while(enumeration.hasMoreElements()){
                NetworkInterface netInterface = (NetworkInterface) enumeration.nextElement();
                Enumeration addresses = netInterface.getInetAddresses();
                while (addresses.hasMoreElements()) {
                    ip = (InetAddress) addresses.nextElement();
                    if (ip != null && ip instanceof Inet4Address){
                     if (“127.0.0.1“.equals(ip.getHostAddress())) {
continue;
}
                     ip1=ip.getHostAddress();
                        
                    } 
                }
            }
        } 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-07-03 16:44  examDemo\
     文件        4702  2018-05-02 10:57  examDemo\crebas.sql
     文件         245  2018-07-03 16:15  examDemo\crebas?猔種.txt
     目录           0  2018-07-03 15:48  examDemo\exam\
     文件      145141  2018-05-02 11:09  examDemo\exam.pdm
     文件         529  2018-07-03 15:06  examDemo\exam\.classpath
     目录           0  2018-07-03 15:06  examDemo\exam\.myeclipse\
     文件         285  2018-07-03 15:06  examDemo\exam\.mymetadata
     文件        1747  2018-07-03 15:38  examDemo\exam\.project
     目录           0  2018-07-03 15:48  examDemo\exam\.settings\
     文件         500  2018-07-03 15:06  examDemo\exam\.settings\.jsdtscope
     文件          88  2018-07-03 15:13  examDemo\exam\.settings\org.eclipse.core.resources.prefs
     文件         395  2018-07-03 15:06  examDemo\exam\.settings\org.eclipse.jdt.core.prefs
     文件         450  2018-07-03 15:06  examDemo\exam\.settings\org.eclipse.wst.common.component
     文件         252  2018-07-03 15:06  examDemo\exam\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2018-07-03 15:06  examDemo\exam\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2018-07-03 15:06  examDemo\exam\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2018-07-03 15:48  examDemo\exam\src\
     文件        4761  2018-07-03 15:47  examDemo\exam\src\applicationContext.xml
     目录           0  2018-07-03 15:48  examDemo\exam\src\com\
     目录           0  2018-07-03 15:48  examDemo\exam\src\com\xl\
     目录           0  2018-07-03 15:48  examDemo\exam\src\com\xl\exam\
     目录           0  2018-07-03 15:48  examDemo\exam\src\com\xl\exam\action\
     文件        3259  2018-07-03 15:35  examDemo\exam\src\com\xl\exam\action\baseAction.java
     文件        2265  2018-07-03 15:35  examDemo\exam\src\com\xl\exam\action\LoginAction.java
     文件        4986  2018-07-03 15:35  examDemo\exam\src\com\xl\exam\action\QuestionsAction.java
     文件        3237  2018-07-03 15:23  examDemo\exam\src\com\xl\exam\action\Test.java
     目录           0  2018-07-03 15:48  examDemo\exam\src\com\xl\exam\dao\
     文件         823  2018-07-03 15:31  examDemo\exam\src\com\xl\exam\dao\baseDao.java
     目录           0  2018-07-03 15:48  examDemo\exam\src\com\xl\exam\dao\impl\
     文件        6263  2018-07-03 15:35  examDemo\exam\src\com\xl\exam\dao\impl\baseDaoImpl.java
............此处省略3434个文件信息

评论

共有 条评论