1.参数传递:
jsp页面用herf方式/get方式传递参数:
<a href="<%=path %>/en/learner/jsp/user_home/uh_frame/jkdmxg.jsp?name=<%=name %>&id=<%=id %>&code=<%=code%>">编辑</a>
jsp页面接受get方式传递的参数:
String id=(String)request.getParameter("id");
jsp页面get方式传递参数时的乱码解决:
String nn=request.getParameter("name");
String name=new String(nn.getBytes("ISO-8859-1"),"UTF-8");
2.表单提交:
页面中有from表单时,可以直接提交到别的jsp页面,from表单的值会默认在request中,直接在页面中用request.getParameter("name");方式就可以取到值.
2.1js方式提交表单到jsp页面:
<form action="" name="jkdmxg" id="jkdmxg">
名称:<input id="jkdm_name" type="text" value=<%=name%> name="jkdm_name">
监考代码:<input id="jkdm_code" type="text" value=<%=code%> name="jkdm_code">
<input type="hidden" name="jkdm_id" value="<%=id%>" id="jkdm_id">
<input id="quxiao" type="button" value="取消" onclick="quxiao1();">
<input id="queding" type="button" value="修改" onclick="queding1();">
</form>
javascript方法:
function queding1(){
var name1=document.jkdmxg.jkdm_name.value;
var code1=document.jkdmxg.jkdm_code.value;
if(name1==null||code1==null||name1==''||code1==''){
alert("名称或监考代码不能为空!");
return null;
}else{
document.jkdmxg.action ='<%=path %>/en/learner/jsp/user_home/uh_frame/jkdmxg1.jsp';
document.jkdmxg.submit();
}
}
3.页面跳转
jsp页面之间的跳转:
<%response.setContentType("text/html; charset=utf-8");
response.sendRedirect(path+"/en/learner/jsp/user_home/uh_frame/jkdmgl.jsp?isok="+isOk);%>
4 工作中遇到的问题:
4.1 在myEclipse中clean后,tomcat和本地工程的classes文件夹下都没有文件,重新编译也不行,试了一切办法都没解决好,最后把本地和myeclipse中的
dh_home工程删除掉,重新检出一份才可以.
4.2 新建的java类在myeclipse中不编译,最后发现时jdk版本错误,把1.6的版本换成1.4的版本就行了.
5.dh_home工程中的表的查询和修改
package parim.net.test;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import oracle.jbo.server.DBTransaction;
import parim.net.cea.uh.bean.UserQuestionData;
public class Jkdmgl extends UserQuestionData{
private PreparedStatement ps = null;
private JkdmModel uqf = new JkdmModel();
private ResultSet rs = null;
private DBTransaction txn = null;
private String strSql = "";
public List jkdmcx(){
ArrayList tlist = null;
try {
this.strSql = "select id,name,code from PROCTOR_CODE";
txn = this.getDBTransaction();
ps = txn.createPreparedStatement(strSql, 1);
rs = ps.executeQuery();
tlist = new ArrayList();
while (rs.next()) {
uqf = new JkdmModel();
uqf.setId(rs.getInt("id"));
uqf.setName(rs.getString("name"));
uqf.setCode(rs.getString("code"));
tlist.add(uqf);
}
}catch(Exception e){
e.printStackTrace();
}finally{
try {
rs.close();
ps.close();
txn.closeTransaction();
} catch (SQLException e) {
e.printStackTrace();
}
}
return tlist;
}
public int jkdmgx(String id,String name,String code,int username){
int id1=Integer.valueOf(id).intValue();
int isOK =0;
try {
this.strSql = "UPDATE PROCTOR_CODE SET name=?,code=? ,last_update_date = sysdate,last_updated_by=? where id=?";
txn = this.getDBTransaction();
ps = txn.createPreparedStatement(strSql, 1);
ps.setString(1, name);
ps.setString(2, code);
ps.setInt(3, username);
ps.setInt(4, id1);
int num =0;
num=ps.executeUpdate();
txn.commit();
if(num>0){
isOK=1;
}
}catch(Exception e){
e.printStackTrace();
}finally{
try {
ps.close();
txn.closeTransaction();
} catch (SQLException e) {
e.printStackTrace();
}
}
return isOK;
}
}