关于jsp<input type='file'/>赋值的问题

本文解释了为何浏览器无法直接为JSP中的文件输入框赋值。为了保护用户隐私及安全,避免服务器非法获取客户端敏感信息,文章说明了当前的安全机制,并强调文件上传必须遵循正规流程。
浏览器出于安全考虑,不能给jsp<input type='file'/>的value赋值,如果能够给它赋值的话,服务器端就很容易的获取到客户端的信息了,如果是这样想谁都不会愿意吧!
例如:我建了个网站,设置了一个隐藏域,是file类型,它的value是“你的银行密码.txt”,你访问我的网站,我的服务器端就能获得你的银行卡密码了,这样你是不会愿意的吧!
所以出于安全考虑不能给jsp<input type="file"/>的value赋值。要把文件上传到服务器上只能按照上传的步骤进行。
<tr> <td>Status:</td> <td colspan="3" style="text-align: left;"><select name="status"> <option value="KITTING" selected="selected">KITTING</option> </select></td> </tr> <tr> <td>FabSite:</td> <td colspan="3" style="text-align: left;"><select name="fab"> <option value="J2A DOI" selected="selected">DOI</option> </select></td> </tr> 明明有值,为什么 String lotId = FormatUtils.parseString(request.getParameter("lotId")); String rackId = FormatUtils.parseString(request.getParameter("rackId")); String status = FormatUtils.parseString(request.getParameter("status")); String fab = FormatUtils.parseString(request.getParameter("fab")); int pageSize = LineSideConstants.PAGE_SIZE_10; Integer pageIndex = FormatUtils.parseInteger(request.getParameter("pageIndex")); if (pageIndex == null) { pageIndex = 0; } RmsBinLotDetail rmsBinLotDetail = new RmsBinLotDetail(); rmsBinLotDetail.setLotId(lotId.trim()); rmsBinLotDetail.setCabinetId(rackId.trim()); rmsBinLotDetail.setStatus(status.trim()); rmsBinLotDetail.setFabsite(fab.trim()); 这两个还是空值? rmsBinLotDetail.setStatus(status.trim()); rmsBinLotDetail.setFabsite(fab.trim()); 完整代码如下: <%@page import="com.sjsemi.lsmm.domain.RmsBinLotDetail" %> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <%@ page import="java.util.*" %> <%@page import="com.sjsemi.lsmm.service.RmsService" %> <%@ page import="org.springframework.web.context.support.WebApplicationContextUtils" %> <%@ page import="org.springframework.context.ApplicationContext" %> <%@ page import="com.sjsemi.lsmm.common.LineSideConstants" %> <%@ page import="com.sjsemi.prms.domain.PagerResult" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title><%=Global.WEB_TITLE %> </title> <% request.setCharacterEncoding("UTF-8"); %> <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <link rel="stylesheet" type="text/css" href="lib/bootstrap/css/bootstrap.css"> <link rel="stylesheet" type="text/css" href="custom/global.css"> <link rel="stylesheet" type="text/css" href="stylesheets/theme.css"> <link rel="stylesheet" href="lib/font-awesome/css/font-awesome.css"> <link rel="stylesheet" type="text/css" href="stylesheets/jquery-ui.css"> <script src="lib/jquery-1.7.2.min.js" type="text/javascript"></script> <script src="lib/jquery-ui-1.10.4.js" type="text/javascript"></script> <!-- Demo page code --> <style type="text/css"> #line-chart { height: 300px; width: 800px; margin: 0px auto; margin-top: 1em; } .brand { font-family: georgia, serif; } .brand .first { color: #FF5C0D; font-style: italic; } .brand .second { color: #fff; font-weight: bold; } </style> <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="lib/html5.js"></script> <![endif]--> <!-- Le fav and touch icons --> <link rel="shortcut icon" href="../assets/ico/favicon.ico"> <link rel="apple-touch-icon-precomposed" sizes="144x144" href="../assets/ico/apple-touch-icon-144-precomposed.png"> <link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png"> <link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png"> <link rel="apple-touch-icon-precomposed" href="../assets/ico/apple-touch-icon-57-precomposed.png"> </head> <% ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext()); RmsService rmsService = (RmsService) appContext.getBean("rmsService"); String lotId = FormatUtils.parseString(request.getParameter("lotId")); String rackId = FormatUtils.parseString(request.getParameter("rackId")); String status = FormatUtils.parseString(request.getParameter("status")); String fab = FormatUtils.parseString(request.getParameter("fab")); int pageSize = LineSideConstants.PAGE_SIZE_10; Integer pageIndex = FormatUtils.parseInteger(request.getParameter("pageIndex")); if (pageIndex == null) { pageIndex = 0; } RmsBinLotDetail rmsBinLotDetail = new RmsBinLotDetail(); rmsBinLotDetail.setLotId(lotId.trim()); rmsBinLotDetail.setCabinetId(rackId.trim()); rmsBinLotDetail.setStatus(status.trim()); rmsBinLotDetail.setFabsite(fab.trim()); PagerResult<RmsBinLotDetail> pagerResult = rmsService.queryRmsBinLotDetailByPage(rmsBinLotDetail, pageIndex); List<RmsBinLotDetail> rmsBinLotDetails = pagerResult.getResultList(); %> <body class=""> <%@ include file="navBar.jsp" %> <%@ include file="sideBar.jsp" %> <div class="content"> <div class="header"> <h1 class="page-title">Search&Report</h1> </div> <div class="container-fluid"> <div class="raw-fluid"> <div class="block span6" style="width: 99%;"> <a href="#tablewidget" class="block-heading" data-toggle="collapse">Search Criteria </a> <div id="tablewidget" class="block-body collapse in"> <form id="frmQuery" action="<%=Page.TD_RMS_LOT_SEARCH %>" method="post"> <input type="hidden" name="menu" value="<%=menu%>"> <input type="hidden" name="function" value="<%=function%>"> <input type="hidden" name="pageIndex"/> <table class="table"> <tr> <td>Lot ID:</td> <td><input type="text" id="lotId" name="lotId" value="<%=lotId %>"></td> </tr> <tr> <td>Cabinet ID:</td> <td><input type="text" id="rackId" name="rackId" value="<%=rackId %>"></td> </tr> <tr> <td>Status:</td> <td colspan="3" style="text-align: left;"><select name="status"> <option value="KITTING" selected="selected">KITTING</option> </select></td> </tr> <tr> <td>FabSite:</td> <td colspan="3" style="text-align: left;"><select name="fab"> <option value="J2A DOI" selected="selected">DOI</option> </select></td> </tr> <tr> <td colspan="4" style="text-align: center;"><input type="submit" class="btn btn-primary btn-small" value="Search" id="btnSearch"/></td> </tr> </table> </form> </div> </div> </div> </div> <div class="container-fluid"> <div class="raw-fluid"> <div class="block span6" style="width: 99%;"> <a href="#tablewidget1" class="block-heading" data-toggle="collapse">Search Result List</a> <div id="tablewidget1" class="block-body collapse in"> <table class="table"> <thead> <tr> <th></th> <th>Cabinet ID</th> <th>Lot ID</th> <th>Physical Lot ID</th> <th>Customer Code</th> <th>Customer Lot ID</th> <th>QTY</th> <th>Product ID</th> <th>Status</th> <th>Action</th> <th>Create Date</th> <th>Operator</th> <th>FabSite</th> <th>BoundFlag</th> </tr> </thead> <tbody> <% for (int i = 0; i < rmsBinLotDetails.size(); i++) { RmsBinLotDetail item = rmsBinLotDetails.get(i); %> <tr> <td><%=pageIndex * pageSize + (i + 1) %> </td> <td><%=item.getCabinetId() %> </td> <td><%=item.getLotId() %> </td> <td></td> <td></td> <td></td> <td></td> <td></td> <td><%=item.getStatus() %> </td> <td></td> <td><%=item.getcDate() %> </td> <td><%=item.getcUser() %> </td> <td><%=item.getFabsite() %> </td> <td></td> </tr> <% } %> </tbody> </table> </div> </div> <div class="pagination"> <ul> <% int pageCount = pagerResult.getPageCount(); int totalShowPage = 10; int startPageIndex = pageIndex - totalShowPage / 2; int endPageIndex = 0; if (startPageIndex < 0) { startPageIndex = 0; } endPageIndex = startPageIndex + 20; if (endPageIndex > pagerResult.getPageCount() - 1) { endPageIndex = pagerResult.getPageCount() - 1; } if (pageIndex > 0) { %> <li><a href="javascript:void(0);" onclick="SearchPage('<%=0 %>');">First</a></li> <li><a href="javascript:void(0);" onclick="SearchPage('<%=pageIndex - 1 %>');">Prev</a></li> <% } if (startPageIndex > 0) { %> <li><a href="javascript:void(0);" onclick="SearchPage('<%=startPageIndex - 1 %>');">...</a></li> <% } for (int i = startPageIndex; i <= endPageIndex; i++) { if (i == pageIndex) { %> <li><a href="#" style="background-color: lightgray;"><%=i + 1 %> </a></li> <% } else { %> <li><a href="javascript:void(0);" onclick="SearchPage('<%=i %>');"><%=i + 1 %> </a></li> <% } } if (endPageIndex < pageCount - 1) { %> <li><a href="javascript:void(0);" onclick="SearchPage('<%=endPageIndex + 1 %>');">...</a></li> <% } if (pageIndex < pageCount - 1) { %> <li><a href="javascript:void(0);" onclick="SearchPage('<%=pageIndex + 1 %>');">Prev</a></li> <li><a href="javascript:void(0);" onclick="SearchPage('<%=pageCount - 1 %>');">Last</a></li> <% } %> </ul> </div> </div> </div> </div> <script src="lib/bootstrap/js/bootstrap.js"></script> <script type="text/javascript"> $(document).ready(function () { $("#frmQuery select[name='status']").val('<%=status %>'); $("#frmQuery select[name='fab']").val('<%=fab %>'); }); function SearchPage(pageIndex) { $("#frmQuery input[name='pageIndex']").val(pageIndex); $("#frmQuery").submit(); } </script> </body> </html>
最新发布
12-04
<sfform:input path="organLevel" id="organLevel" value="1234" type="hidden"></sfform:input> <sfform:form modelAttribute="filterMask" id="agentInfo"> <div class="layout_div"> <div class="navigation_div"> <span class="font_heading1">业务员查询>></span> </div> <fieldset class="fieldsetdefault"> <legend>查询</legend> <table class="layouttable" id="input_info"> <tr> <td class="layouttable_td_label">机构:</td> <td class="zTreeDemoBackground left"><%@ include file="/WEB-INF/views/commons/organ.jsp"%> </td> <td class="layouttable_td_label">推荐人编码:</td> <td class="layouttable_td_widget"><sfform:input path="recommenderCode" id="recommenderCode" class="input_text" /></td> <td class="layouttable_td_label">推荐人姓名:</td> <td class="layouttable_td_widget"><sfform:input path="recommenderName" id="recommenderName" class="input_text" /> </td> </tr> <tr> <td class="layouttable_td_label">证件号码:</td> <td class="layouttable_td_widget"><sfform:input path="idNo" id="idNo" class="input_text" /></td> <td class="layouttable_td_label">姓名:</td> <td class="layouttable_td_widget"><sfform:input path="agentName" id="agentName" class="input_text" /></td> <td class="layouttable_td_label">审核状态:</td> <td class="layouttable_td_widget"><sfform:select path="ratifyStatus" id="ratifyStatus" class="input_text"> <c:if test="${user.role_id ne '010027' && user.role_id ne '120027'}"> <sfform:option value="1">待复核 </sfform:option> </c:if> <c:if test="${user.organ_level ne '3' && user.organ_level ne '4'}"> <sfform:option value="7">待二级机构复核 </sfform:option> </c:if> <c:if test="${user.role_id eq '010027' || user.role_id eq '120027'}"> <sfform:option value="5">待总公司人力发展岗复核 </sfform:option> </c:if> <c:if test="${user.role_id eq '010001' || user.role_id eq '010002' || user.role_id eq '010003' || user.role_id eq '120001' || user.role_id eq '120002' || user.role_id eq '120003'}"> <sfform:option value="6">待总公司人管岗复核</sfform:option> </c:if> <sfform:option value="4">复核不通过</sfform:option> <sfform:input path="organLevel" id="organLevel" value="1234"里面的organLevel可以替换user.Organ_level吗
11-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值