问题描述
- 在javaweb里面如果是html页面,要设计成先登录才能访问这个html页面,怎么做?
-
如题,jsp和servlet有办法,但是html页面如果不让未登录者访问?
解决方案
增加filter,检查是否有用户登录的标记。
解决方案二:
DataStormSession session = DataStormSession.getInstance();
HttpServletResponse response = ServletActionContext.getResponse();
String sql = "select * from zcgl.product where product_code='"
+ product.getProductCode() + "'";
List list = session.findSql(sql);
if (list.size() > 0) {
resultStr = "exist";
}
if(resultStr.equals("success")){
sql = "insert into zcgl.product (department_id,department_name,product_code,product_name,class_code,product_version,specification,price,manufacturers,product_use,receive_user,in_time,product_status,manage_user,use_user,address,last_out_time,remark,oper_user,oper_time) values ('"
+ product.getDepartmentId()
+ "','"
+ product.getDepartmentName()
+ "','"
+ product.getProductCode()
+ "','"
+ product.getProductName()
+ "','"
+ product.getClassCode()
+ "','"
+ product.getProductVersion()
+ "','"
+ product.getSpecification()
+ "','"
+ product.getPrice()
+ "','"
+ product.getManufacturers()
+ "','"
+ product.getProductUse()
+ "','"
+ product.getReceiveUser()
+ "','"
+ product.getInTime()
+"','"
+ product.getProductStatus()
+ "','"
+ product.getManageUser()
+ "','"
+ product.getUseUser()
+ "','"
+ product.getAddress()
+ "','"
+ product.getLastOutTime() + "','" + product.getRemark() + "','" + operUserName + "',sysdate())";
logger.info("增加资产:"+sql);
session.add(sql);
}
session.closeSession();
解决方案三:
用户登陆将用户信息存储到session 利用过滤器判断session是否有用户信息
if 有 则允许访问
else
重定向提醒登陆
时间: 2024-09-30 02:09:11