View Mode: Normal | Article List
Category: Java | < | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | >

数组判断参数

[ 2004-09-09 01:10:11 | Author: zhenhua ]
之前<%=ds.getString("DATA")%>
之后
<%=(ds.getString("DATA").equals("1")?"A":ds.getString("DATA").equals("2")?"B":ds.getString("DATA"))%>


数组
之前<%=fn[x]%>
之后
<%=(fn[x].equals("")?"无":"<a href=/upload/office_notice/"+URLEncoder.encode(fn[x])+"target=_blank>"+fn[x]+"</a>")%>

用哈希保存数据

[ 2004-09-09 01:08:06 | Author: zhenhua ]
<jsp:useBean id="data" scope="page" class="com.soft.data" />

<%
 HashMap hs = (HashMap)session.getAttribute("SYSTEM_NEXTPAGE");
 String id1 = request.getParameter("id1");
 String id2= request.getParameter("id2");
 String id3= request.getParameter("id3");
 String id4= request.getParameter("id4");
 HashMap save = new HashMap();
 save.put("id1",id1);
 save.put("id2",id2);
 save.put("id3",id3);
 save.put("id4",id4);

 boolean flag =data.adddata(save); //flag:false/true
%>
用变量替换的方式存取,用“ ;” 分号间隔

存入:
<%
String scapegoat = "";
 scapegoat+=循环数值+";";
 save.put("真实字段",scapegoat ); //这里用HashMap仍进数据库,save:哈希名
%>
 

取出:
<%
String scapegoat = ds.getString("字段名");
String [] sc = scapegoat.split(";"); //split 处理
for(int i=0;i<sc.length;i++){ //for 循环
%>

<%=sc%> // 列出数据

<%
}
%>

中文URL字符转换

[ 2004-09-09 01:05:20 | Author: zhenhua ]
使用Java.net 包
<%@page import="java.net.*">

输出方式:<%=URLEncoder.encode(中文文件名)%>
<a href="http://www.www.com/down/<%=URLEncoder.encode(中文文件名)%>">

JAVA/JSP一次性上传多个附件

[ 2004-09-09 01:04:14 | Author: zhenhua ]
方法1:
利用 Oreilly MultiPartRequest
使用方法:
File.htm
<html>
<head>
<title>File Upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
</head>
<body bgcolor="#FFFFFF" text="#000000"><p><font size="5"color="#FF0000">
<b>上传示例</b></font></p>

<form name="Form1" enctype="multipart/form-data" method="post" action="File.jsp">
<p>文件 1: <input type="file"name="File1" size="20" maxlength="20"> </p>
<p>描述: <input type="text" name="File1" size="30" maxlength="50"> </p>
...

Read More...

表单参数传递写法

[ 2004-09-09 01:03:40 | Author: zhenhua ]
<select name="formname">
<option value=1<%=(dataname.equals("1")?" selected":"")%>>A</option>
<option value=2<%=(dataname.equals("2")?" selected":"")%>>B</option>
<option value=3<%=(dataname.equals("3")?" selected":"")%>>C</option>
<option value=4<%=(dataname.equals("4")?" selected":"")%>>D</option>
<option value=5<%=(dataname.equals("5")?" selected":"")%>>E</option>
</select>
前台输出代码:
<%=(ds.getString("DATANAME").equals("1")?"A":ds.getString("DATANAME").equals("2")?"B":ds.getString("DATANA
...

Read More...

获取参数

[ 2004-09-09 01:02:37 | Author: zhenhua ]
<%
 String test = ds.getString("TEST");
 String color = "black";
 if(iserror.equals("1")){
 color = "red";
}
%>
<%=color%>


判断开头字符:
startsWith 代替equals

项目架构思想

[ 2004-09-09 01:02:09 | Author: zhenhua ]
JAVA开发模式三层结构

1.后台 (接收前台数据和处理数据)
2.Controller (连接前后的桥梁)
3.前台 (web页面接收数据)