笔试JSP2考试答案_第1页
笔试JSP2考试答案_第2页
笔试JSP2考试答案_第3页
笔试JSP2考试答案_第4页
笔试JSP2考试答案_第5页
已阅读5页,还剩18页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

就业强化测试四种会话跟踪技术

会话跟踪是为了跟踪用户于service之间的多次交互.

1.cookie也就是我们常见的在C盘/文件夹下有一个COOKIE目录

2.session比Cookie安全.不可见.但占用srevice资源

3.url重写.这是在用户的IE禁止Cookie的时候采用的方法。因为不管是Cookie还是session都要借助Cookie

4.还有可以用hidden隐藏域Servlet的生命周期,并说出Servlet与CGI的区别。

Servlet被服务器实例化后,容器运行其init方法,请求到达时运行其service方法,service方法自动派遣运行与请求对应的doXXX方法(doGet,doPost)等,当服务器决定将实例销毁的时候调用其destroy方法。

与cgi的区别在于servlet处于服务器进程中,它通过多线程方式运行其service方法,一个实例可以服务于多个请求,并且其实例一般不会销毁,而CGI对每个请求都产生新的进程,服务完成后就销毁,所以效率上低于servlet。jsp中,session对象存在哪个地方,如何进行存取,存在服务器哪个地方,如何存的?

session保存在服务器的内存里面的。针对每一个刚刚打开的浏览器生成一个sessionid作为唯一标识。

在jsp中可以直接用session内置对象,

在servlet中可以用request.getSession()获得session

要往session中存对象可用session.setAttribute(key,object)

取对象可用session.getAttribute(key)写一个JavaScript方法,反选面页面中所有的checkbox?

<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN">

<html>

<head>

<title>MyHtml.html</title>

<metahttp-equiv="keywords"content="keyword1,keyword2,keyword3">

<metahttp-equiv="description"content="thisismypage">

<metahttp-equiv="content-type"content="text/html;charset=UTF-8">

<!--<linkrel="stylesheet"type="text/css"href="./styles.css">-->

<scriptlanguage="JavaScript">

functionCheckAll()

{

for(vari=0;i<document.form1.isDo.length;i++){//遍历后有的多选框

vartemp=document.form1.isDo[i];

temp.checked=!temp.checked;//返选

}

}

</script>

</head>

<body>

<formname="form1">//“form1”是表单名称,需要根据实际情况修改

a<inputtype="checkbox"name="isDo">//“isDo”是复选框名称,根据实际情况修改

b<inputtype="checkbox"name="isDo">

c<inputtype="checkbox"name="isDo">

<inputtype="button"value="返选"onclick="CheckAll()">//关于触发事件调用CheckAll()方法

</form>

</body>

</html><%…%>和<%!…%>的区别

<%…%>用于在JSP页面中嵌入Java脚本

<%!…%>用于在JSP页面中申明变量或方法,可以在该页面中的<%…%>脚本中调用,声明的变量相当于Servlet中的定义的成员变量。使用正则表达试获取页面上的所有图片的地址

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="/1999/xhtml">

<head>

<metahttp-equiv="Content-Type"content="text/html;charset=gbk"/>

<title>demo</title>

<scripttype="text/javascript">

functiongetImages(){

varregx=/(<img\s.*?)(src(?:=\"|=\'|=))(.+?)(?:\"\s|\'\s|\s|\">|\'>|>)/gi;

varresult=document.body.innerHTML.match(regx);

for(vari=0;i<result.length;i++){

varsrcregx=/(src(?:=\"|=\'|=))(.+?)(?:\"|\'|\s)/gi;

varsrc_result=result[i].match(srcregx);

if(src_result){

varr=/(src(?:=\"|=\'|=))|\'|"/gi;

alert(src_result[0].replace(r,""));

}

}

}

</script>

</head>

<body>

<imgwidth="100"src="aaa1.jpg"></img>

<div>

<imgsrc="aaa2.jpg"></img>

<div>

<imgsrc="aaa3.jpg"/>

</div>

</div>

<buttononclick="getImages();">获取</button>

</body>

</html>事务机制的理解,如何有效的定制事务?

同步发生数据更新时,防止数据的不一致。

这些就是数据库特有的术语了。数据库事务是指作为单个逻辑工作单元执行的一系列操作。

设想网上购物的一次交易,其付款过程至少包括以下几步数据库操作:

·更新客户所购商品的库存信息

·保存客户付款信息--可能包括与银行系统的交互

·生成订单并且保存到数据库中

·更新用户相关信息,例如购物数量等等

正常的情况下,这些操作将顺利进行,最终交易成功,与交易相关的所有数据库信息也成功地更新。但是,如果在这一系列过程中任何一个环节出了差错,例如在更新商品库存信息时发生异常、该顾客银行帐户存款不足等,都将导致交易失败。一旦交易失败,数据库中所有信息都必须保持交易前的状态不变,比如最后一步更新用户信息时失败而导致交易失败,那么必须保证这笔失败的交易不影响数据库的状态--库存信息没有被更新、用户也没有付款,订单也没有生成。否则,数据库的信息将会一片混乱而不可预测。写程序用pop3收取gmail的邮件

GMAIL的端口和连接方式比较特殊:

SMTP端口为:456

POP3端口为:995

都采用安全连接(SSL)

这些通过Indy组件就可以实现

SSL需要如下两个动态连接库

ssleay32.dll

libeay32.dll

Foxmail目录里就有,复制到程序的当前目录即可

要最新的才可以~~~要在上面下载到最近的才能连接如何编写一个文件上传JavaBean?

upload.jsp

<%@pageimport="com.upload.upload"%>

<%

StringDir="/home/tonywan/upload";

uploadupload=newupload();

upload.setUploadDirectory(Dir);

upload.uploadFile(request);

out.print("<center><fontcolor=red>成功上载文件至"+Dir+"</font></center>");

%>

upload.html

<center>Fileuploadtest</center>

<br>

<table><tr>

<formmethod="post"enctype="multipart/form-data"action="upload.jsp">

<td><inputtype=filesize=20name="fname"></td>

<td><inputtype=Submitvalue=Upload></td></form>

</tr></table>

packagecom.upload;

importjava.io.*;

importjavax.servlet.http.HttpServletRequest;

importjavax.servlet.ServletInputStream;

importjavax.servlet.ServletException;

publicclassupload{

privatestaticStringnewline="\n";

privateStringuploadDirectory=".";

privateStringContentType="";

privateStringCharacterEncoding="";

privateStringgetFileName(Strings){

inti=s.lastIndexOf("\\");

if(i<0//i>=s.length()-1){

i=s.lastIndexOf("/");

if(i<0//i>=s.length()-1)

returns;

}

returns.substring(i+1);

}

publicvoidsetUploadDirectory(Strings){

uploadDirectory=s;

}

publicvoidsetContentType(Strings){

ContentType=s;

intj;

if((j=ContentType.indexOf("boundary="))!=-1){

ContentType=ContentType.substring(j+9);

ContentType="--"+ContentType;

}

}

publicvoidsetCharacterEncoding(Strings){

CharacterEncoding=s;

}

publicvoiduploadFile(HttpServletRequestreq)throwsServletException,IOException{

setCharacterEncoding(req.getCharacterEncoding());

setContentType(req.getContentType());

uploadFile(req.getInputStream());

}

publicvoiduploadFile(ServletInputStreamservletinputstream)throwsServletException,IOException{

Strings5=null;

Stringfilename=null;

byteLinebyte[]=newbyte[4096];

byteoutLinebyte[]=newbyte[4096];

intai[]=newint[1];

intai1[]=newint[1];

Stringline;

//得到文件名

while((line=readLine(Linebyte,ai,servletinputstream,CharacterEncoding))!=null){

inti=line.indexOf("filename=");

if(i>=0){

line=line.substring(i+10);

if((i=line.indexOf("\""))>0)

line=line.substring(0,i);

break;

}

}

filename=line;

if(filename!=null&&!filename.equals("\"")){

filename=getFileName(filename);

StringsContentType=readLine(Linebyte,ai,servletinputstream,CharacterEncoding);

if(sContentType.indexOf("Content-Type")>=0)

readLine(Linebyte,ai,servletinputstream,CharacterEncoding);

//File(Stringparent,Stringchild)

//CreatesanewFileinstancefromaparentpathnamestring

//andachildpathnamestring.

Filefile=newFile(uploadDirectory,filename);

//FileOutputStream(Filefile)

//Createsafileoutputstreamtowritetothefilerepresented

//bythespecifiedFileobject.

FileOutputStreamfileoutputstream=newFileOutputStream(file);

while((sContentType=readLine(Linebyte,ai,servletinputstream,CharacterEncoding))!=null){

if(sContentType.indexOf(ContentType)==0&&Linebyte[0]==45)

break;

if(s5!=null){

//write(byte[]b,intoff,intlen)

//Writeslenbytesfromthespecifiedbytearraystarting

//atoffsetofftothisfileoutputstream.

fileoutputstream.write(outLinebyte,0,ai1[0]);

fileoutputstream.flush();

}

s5=readLine(outLinebyte,ai1,servletinputstream,CharacterEncoding);

if(s5==null//s5.indexOf(ContentType)==0&&outLinebyte[0]==45)

break;

fileoutputstream.write(Linebyte,0,ai[0]);

fileoutputstream.flush();

}

bytebyte0;

if(newline.length()==1)

byte0=2;

else

byte0=1;

if(s5!=null&&outLinebyte[0]!=45&&ai1[0]>newline.length()*byte0)

fileoutputstream.write(outLinebyte,0,ai1[0]-newline.length()*byte0);

if(sContentType!=null&&Linebyte[0]!=45&&ai[0]>newline.length()*byte0)

fileoutputstream.write(Linebyte,0,ai[0]-newline.length()*byte0);

fileoutputstream.close();

}

}

privateStringreadLine(byteLinebyte[],intai[],

ServletInputStreamservletinputstream,

StringCharacterEncoding){

try{

//readLine(byte[]buffer,intoffset,intlength)

//ReadsalinefromthePOSTdata.

ai[0]=servletinputstream.readLine(Linebyte,0,Linebyte.length);

if(ai[0]==-1)

returnnull;

}catch(IOException_ex){

returnnull;

}

try{

if(CharacterEncoding==null){

//用缺省的编码方式把给定的byte数组转换为字符串

//String(byte[]bytes,intoffset,intlength)

returnnewString(Linebyte,0,ai[0]);

}else{

//用给定的编码方式把给定的byte数组转换为字符串

//String(byte[]bytes,intoffset,intlength,Stringenc)

returnnewString(Linebyte,0,ai[0],CharacterEncoding);

}

}catch(Exception_ex){

returnnull;

}

}

/*

publicintreadLine(byte[]buffer,

intoffset,

intlength)throwsjava.io.IOException

从POST来的数据中读一行

参数:

buffer-buffertoholdthelinedata

offset-offsetintothebuffertostart

length-maximumnumberofbytestoread.

Returns:

numberofbytesreador-1ontheendofline.

*/

}smtp的中文含义是什么?一般用什么端口?pop3中文含义和端口?

SMTP(简单邮件传输协议)、POP3(邮局协议)

smtp25端口

pop3110端口

SMTP(SimpleMailTransferProtocol):SMTP主要负责底层的邮件系统如何将邮件从一台机器传至另外一台机器。

POP(PostOfficeProtocol):目前的版本为POP3,POP3是把邮件从电子邮箱中传输到本地计算机的协议。你认为哪种分页效率最高?

JSP

,MYSQL,SQL2005.

SQL2005效率高:

因为mysql的分页还是先查出所有的记录,再从起始位置开始查出所需要的记录,

而SQL2005不会查所有记录,只查筛选后所需要的记录说出在JSP页面里是怎么分页的?

通过jsp页面把包含了分页的信息封装到Pagination对象中,再把Pagination对象传到servlet中,servlet取出当前的页数等信息,再调用DAO中的方法查出相应的结果集,servlet再把查出的结果集传到jsp中显示

示例代码如下:

packagecom.onechen.page;

publicclassPagination{

publicPagination(){

}

publicstaticStringgetPaginationScript(intcurrPage,intpageNum,intrecordNum,Stringurl){

StringBuffersb=newStringBuffer();

intrecordNum=recordNum;//总记录数

intstartRecord=0;//开始的记录数

intendRecord=0;//结束的记录数

intpagesNum=0;//总页数

intlineNum=pageNum;//每页显示的记录数

intcurrentPage=currPage;//当前页if(recordNum>0){

pagesNum=(int)(recordNum/lineNum);

if((recordNum%lineNum)!=0)

pagesNum++;

}

startRecord=currentPage*lineNum;

endRecord=startRecord+lineNum;

if(endRecord>recordNum)

endRecord=recordNum;

sb.append("<CENTER><tableborder=0width=800cellspacing=0cellpadding=0bgcolor=#e8f4ff>");

sb.append("<trheight=30><tdalign=left>");

sb.append("共<fontcolor=#333333><b>"+recordNum+"</b></font>条记录

");

sb.append("本页显示<fontcolor=\"#333333\">"+((recordNum>0)?(startRecord+1):0)+"-"+(endRecord)+"</font>条,");

sb.append("第<fontcolor=\"#333333\">"+((recordNum>0)?(currentPage+1):0)+"/"+pagesNum+"</font>页</td>");

sb.append("<tdalign=right>");

if(currentPage==0)

{

sb.append("【最前页】【上一页】");

}

else

{

sb.append(

"|<ahref="+url+"?pages=0>【最前页】</a>");

sb.append("<ahref="+url+"?pages="+(current1)

+">【上一页】</a>");

}

1、分页beans

pageNumber.java

packagebean;

publicclassPageNumber

{

introwCount=1,//总的记录数

pageSize=1,//每页显示的记录数

showPage=1,//设置预显示的页码数

pageCount=1;//分页之后的总页数

publicvoidsetRowCount(intn){

rowCount=n;

}

publicintgetRowCount(){

returnrowCount;

}

publicvoidsetPageCount(intr,intp){

rowCount=r;

pageSize=p;

pageCount=(rowCount%pageSize)==0?(rowCount/pageSize):(rowCount/pageSize+1);

//计算分页之后的总页数

}

publicintgetPageCount(){

returnpageCount;

}

publicvoidsetShowPage(intn){

showPage=n;

}

publicintgetShowPage(){

returnshowPage;

}

publicvoidsetPageSize(intn){

pageSize=n;

}

publicintgetPageSize(){

returnpageSize;

}

}

2、数据库连接beans

packagebean;

importjava.sql.*;

importjava.io.*;

publicclassMyConnection{

Connectioncon=null;//声明一个共享的连接对象

Statementstat=null;

ResultSetrs=null;

introwCount=0;//总的记录数

publicMyConnection(){

try{

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");

}catch(ClassNotFoundExceptione){

System.out.print(e);

}

try{

con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;

DatabaseName=student;","sa","");

}catch(SQLExceptione){

System.out.print(e);

}

}

publicResultSetmyQuery(Stringsql)throwsSQLException{

//结果集的游标可上下移动,但当数据库变化时,结果集不变,

//不能用结果集更新数据库中的表

stat=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,

ResultSet.CONCUR_READ_ONLY);

//返回可滚动的结果集

rs=stat.executeQuery(sql);

returnrs;

}

publicvoidmyClose()throwsSQLException{

con.close();

}

}

3、分页显示记录的JSP页面

<%@pagecontentType="text/html;charset=gb2312"%>

<%@pageimport="java.sql.*"%>

<%@pageimport="bean.PageNumber"%>

<%@pageimport="bean.MyConnection"%>

<%@pageimport="java.io.*"%>

<jsp:useBeanid="handlePage"class="bean.PageNumber"scope="session"/>

<jsp:useBeanid="myCon"class="bean.MyConnection"scope="application"/>

<HTML>

<BODYbgcolor=cyan><Size=1>

<CENTER>

<BR><BR>

<%!

//以表格形式显示数据库记录的方法

publicvoidshowList(ResultSetrs,JspWriterout,intn){

try{

out.print("<BR><BR><Tableborder=2><tr><th>学号<th>姓名<th>数学<th>英语<th>物理</tr>");

for(inti=1;i<=n;i++){

out.print("<tr>");

Stringnumber=rs.getString(1);

out.print("<td>"+number+"</td>");

Stringname=rs.getString(2);

out.print("<td>"+name+"</td>");

intmath=rs.getInt(3);

out.print("<td>"+math+"</td>");

intenglish=rs.getInt(4);

out.print("<td>"+english+"</td>");

intphysics=rs.getInt(5);

out.print("<td>"+physics+"</td>");

out.print("</tr>");

rs.next();

}

out.print("</table>");

}catch(Exceptione){

System.out.println(e);

}

}

%><%

ResultSetrs=null;

introwCount=0;//总的记录数

try{

//返回可滚动的结果集

rs=myCon.myQuery("select*fromstudents");

//将游标移动到最后一行

rs.last();

//获取记录总数

rowCount=rs.getRow();

//设置每页显示的记录数

handlePage.setPageSize(2);

//计算总页数

handlePage.setPageCount(rowCount,handlePage.getPageSize());

out.print("共有"+handlePage.getPageCount()+"页,");

out.print("每页显示"+handlePage.getPageSize()+"条记录");

}catch(SQLExceptione){

out.print(e);

}

%>

<%--选择显示某页的表单--%>

<%Stringstr=response.encodeRedirectURL("showList.jsp");//获取showList.jsp的url%>

<Formaction="<%=str%>"method="post">

显示首页:<InputType="hidden"name="a"value="first">

<inputtype=submitvalue="first">

</form>

<Formaction="<%=str%>"method="post">

显示下一页:<InputType="hidden"name="a"value="next">

<inputtype=submitvalue="next">

</form>

<Formaction="<%=str%>"method="post">

显示上一页:<InputType="hidden"name="a"value="previous">

<inputtype=submitvalue="previous">

</form>

<Formaction="<%=str%>"method="post">

输入要显示的页数:<InputType="text"name="a"value="1"style="text-align:right">

<inputtype=submitvalue="submit">

</form>

<%

Strings=request.getParameter("a");

if(s==null){

s="1";

}elseif(s.equals("first")){

handlePage.setShowPage(1);//设置预显示页

out.print("目前显示第"+handlePage.getShowPage()+"页");

//将游标移到指定的位置

rs.absolute(1);

//显示该页的内容

showList(rs,out,handlePage.getPageSize());

}elseif(s.equals("next")){

intn=handlePage.getShowPage();//获取目前的页数

n=(n+1);//将页数增1

if(n>handlePage.getPageCount())n=1;

handlePage.setShowPage(n);//设置预显示页

out.print("目前显示第"+handlePage.getShowPage()+"页");

//将游标移到指定的位置

rs.absolute((n-1)*handlePage.getPageSize()+1);

//显示该页的内容

showList(rs,out,handlePage.getPageSize());

}elseif(s.equals("previous")){

intn=handlePage.getShowPage();//获取目前的页数

n=n-1;//将页数减1

if(n<=0)n=handlePage.getPageCount();

handlePage.setShowPage(n);//设置预显示页

out.print("目前显示第"+handlePage.getShowPage()+"页");

//将游标移到指定的位置

rs.absolute((n-1)*handlePage.getPageSize()+1);

//显示该页的内容

showList(rs,out,handlePage.getPageSize());

}else{

intm=Integer.parseInt(s);//把输入的字符转化为整型数

handlePage.setShowPage(m);//设置预显示页

out.print("目前显示第"+handlePage.getShowPage()+"页");

intn=handlePage.getShowPage();

//将游标移到指定的位置

rs.absolute((n-1)*handlePage.getPageSize()+1);

//显示该页的内容

showList(rs,out,handlePage.getPageSize());

}

%>

</CENTER>

</BODY>

</HTML>Java的国际化

可用java自带的国际化:

可用到下面的3个类

importjava.text.MessageFormat;

importjava.util.Locale;

importjava.util.ResourceBundle;实现SqlServer2000的分页,写出sql,并简单描述如何在Java程序中实现?

selecttop2*fromstu2where--查前2条

stuidnotin(selecttop2stuidfromstu2)--排除了前2条

SELECTTOP页大小*

FROMtable1

WHEREidNOTIN

(

SELECTTOP页大小*(页数-1)idFROMtable1ORDERBYid

)

ORDERBYid

SELECTTOP页大小*

FROMtable1

WHEREidNOTIN

(

SELECTTOP页大小*(页数-1)idFROMtable1ORDERBYid

)

ORDERBYid

<%@pagelanguage="java"import="java.util.*"pageEncoding="GBK"%>

<jsp:directive.pageimport="javaBean.UserInfo"/>

<%

Stringpath=request.getContextPath();

StringbasePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN">

<html>

<head>

<basehref="<%=basePath%>">

<title>MyJSP'list.jsp'startingpage</title>

<metahttp-equiv="pragma"content="no-cache">

<metahttp-equiv="cache-control"content="no-cache">

<metahttp-equiv="expires"content="0">

<metahttp-equiv="keywords"content="keyword1,keyword2,keyword3">

<metahttp-equiv="description"content="Thisismypage">

<!--

<linkrel="stylesheet"type="text/css"href="styles.css">

-->

</head>

<body>

<%

inttotalPage=(Integer)session.getAttribute("tatlaPage");

intthisPage=(Integer)session.getAttribute("thisPage");

ArrayList<UserInfo>arrayList=(ArrayList<UserInfo>)request.getAttribute("userInfos");

Iterator<UserInfo>it=arrayList.iterator();

while(it.hasNext()){

UserInfouserInfo=it.next();

%>

<%=userInfo.getUserId()%>

<%=userInfo.getUserName()%>

<%=userInfo.getPassWord()%>

<br>

<%

}

%>

<ahref="/page/servlet/MyServlet?page=1">首页</a>

<%

if(thisPage>1){

%>

<ahref="/page/servlet/MyServlet?page=<%=this1%>">上一页</a>

<%

}

%>

<%

if(thisPage<totalPage){

%>

<ahref="/page/servlet/MyServlet?page=<%=thisPage+1%>">下一页</a>

<%

}

%>

<ahref="/page/servlet/MyServlet?page=<%=totalPage%>">尾页</a>

<formaction="/page/servlet/MyServlet">

<selectname="page">

<%

for(inti=1;i<=totalPage;i++){

if(i==thisPage){

%>

<optionvalue="<%=i%>"selected="selected"><%=i%>

<%

}else{

%>

<optionvalue="<%=i%>"><%=i%>

<%

}

}

%>

</select>

<inputtype="submit"value="go">

</form>

<formaction="/page/servlet/MyServlet">

<inputtype="text"name="page">

<inputtype="submit"value="go">

</form>

<%=thisPage%>/<%=totalPage%>

</body>

</html>

publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)

throwsServletException,IOException{

//取出超链结中传过来的参数

StringpageString=request.getParameter("page");

intpage=1;

if(pageString!=null){

page=Integer.parseInt(pageString);

}

//得到session

HttpSessionsession=request.getSession();

//从session中取出当前是第几页,如果返回为空,则默认当前是第一页,

Objectobj=session.getAttribute("thisPage");

if(obj==null){

session.setAttribute("thisPage",1);

//否则当前页为从超链结中传过来的页数

}else{

session.setAttribute("thisPage",page);

}

MyDAOdao=newMyDAO();

//根据page的页数,返回第页的内容

ArrayList<UserInfo>arrayList=dao.listAllUserInfo(page);

//将返回的内容存入request

request.setAttribute("userInfos",arrayList);

//将总页数保存在session中

if(session.getAttribute("tatlaPage")==null){

inttatlaPage=dao.getTotalPage();

session.setAttribute("tatlaPage",tatlaPage);

}

request.getRequestDispatcher("/list.jsp").forward(request,response);//转发到list.jsp页面url:不变;发送request内容

//response.sendRedirect("/list.jsp");//重定向url:变;不发送request内容

}JSP里form上传文件的时候用到form标签的encType属性,但这样在另一个页面用request.getParameter()方法是得不到表单的值的,为什么?用什么方法可以得到?

直接request.getParameter来取参数值是取不到的

我们可以借用apache的上传组件来解决

用到jar包commons-fileupload-1.1.1.jar

importmons.fileupload.FileItem;

importmons.fileupload.FileItemFactory;

importmons.fileupload.FileUploadException;

importmons.fileupload.disk.DiskFileItemFactory;

importmons.fileupload.servlet.ServletFileUpload;

/**

*获取各种类型表单的表单参数

*@paramrequestHttpServletRequest请求对像

*@paramparamName参数名

*@return

*@throwsFileUploadException

*/

publicstaticStringgetParameterValue(HttpServletRequestrequest,StringparamName)throwsFileUploadException{

booleanisMultipart=ServletFileUpload.isMultipartContent(request);

if(isM

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论