jsp 有身体的组件

componentWithBody.jsp
<%@ tag body-content="scriptless" trimDirectiveWhitespaces="true"%>
<%@ attribute name="attr" required="false" %>

${attr}

<div class="body">
  <jsp:doBody/>
</div>
template.jsp
<%@ taglib prefix="component" tagdir="/WEB-INF/tags/shared/component" %>

<component:componentWithBody attr="Hello world!">
    // Content here
</component:componentWithBody>

jsp 按钮单击功能

timeTable.jsp
<script>
    $("#btnSearch").on('click',function () {
        $("#btnSearch").hide();
    });
</script>

jsp 随机数

random-number
<jsp:useBean id="random" class="java.util.Random" scope="application" />
<c:set var="galleryId" value="gallery-${random.nextInt(99999999)}"/>

jsp 分页控件字段加自定义链接

colString
colString.append("<col width=\"30%\"  text=\"" + "标题" + "\" column=\"wjbt\" orderkey=\"wjbt\"  href=\"/workflow/request/ViewRequest.jsp\" linkkey=\"requestid\" linkvaluecolumn=\"reqid\" target=\"_fullwindow\" />");

jsp 下载附件

downloadAttach
<%!
int getImagefileId(String docid){
	int imagefileid = -1;
	
	if(docid.equals("")){
		return imagefileid;
	}
	
	RecordSet rs = new RecordSet();
	rs.execute("select imagefileid from docimagefile where docid=" + docid);
	if(rs.next()){
		imagefileid = Util.getIntValue(rs.getString("imagefileid"), 0);
	}
	
	return imagefileid;
}
%>

<%
int imagefileid_ = getImagefileId(docid);
%>
<img src="/weaver/weaver.file.FileDownload?fileid=<%=imagefileid_%>" width="100%" height="100%">

jsp wegget

只是测试

alert
alert('hello just test')

jsp TAG LIBRARIES DE SPRING Y ESTANDAR JSP

TAG LIBRARIES DE SPRING Y ESTANDAR JSP

.jsp

/*LA CONSTRUCCION DE UNA PANTALLA SE DEBERA DE REALIZAR MEDIANTE EL USO DE JSP
Y CON EL APOYO DE LIBRARY TAG DE SPRING*/
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

/*OPCIONAL*/
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

/*EJEMPLO DE USO*/
<fmt:parseNumber value="${pagina}" var="nPagina"/>
  <c:if test="${nPagina>0}">
    <table width="100%" border="1">
      <tr align="center">
        <td colspan="5">Pagina: ${pagina}</td>
      </tr>
      <tr align="center">
        <td>Contacto</td>
        <td>Telefono</td>
        <td>Servicio</td>
        <td>Agente</td>
        <td>Estado</td>
      </tr>
<c:forEach var="regs" items="${registros}">
    <tr>
      <td> ${regs.idContacto}</td>
      <td> ${regs.telefono}</td>
      <td> ${regs.descServicio}</td>
      <td> ${regs.nombreAgente}</td>
      <td> ${regs.idEstadoContacto}</td>
    <tr>
</c:forEach>
</table>
</c:if>

jsp JS删除提示框和整数类型参数传递

JS删除提示框

1.js
function delCust(lkmId) {
    var sure = window.confirm("确定删除此用户么?");
    if(sure) {
        window.location.href = "${pageContext.request.contextPath}/linkman/deleteLinkman?lkmId=" + lkmId;
    }
}
1.jsp
<a href="javascript:delCust('${lkmId}')">删除</a>

<%--
    javascript: -> 作用是告诉a标签的href属性执行脚本代码
    
    js函数传入的参数要用''包围起来!!!
--%>

jsp JSP基础2

JSPでクラスをインポートする

Kirby
// プロジェクトフォルダ > Java リソース > src > model > Kirby.java
package model;

public class Kirby {
	private String id;
	private String name;
	public Employee(String id, String name) {
		this.id = id;
		this.name = name;
	}
	public String getId() { return id; }
	public String getName() { return name; }

}
index
// プロジェクトフォルダ > WebContent > index.jsp
<!-- pageディレクティブでクラスも一緒にインポート -->
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="model.Kirby" %>
<%
Kirby krb = new Kirby("0001", "GREEN GREENS");
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>SampleJSP</title>
</head>
<body>
<p>IDは<%= krb.getId() %>、名前は<%= krb.getName() %>です</p>
</body>
</html>

jsp 将时间戳值转换为日期时间

formatedDate.jsp
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<jsp:useBean id="dateObject" class="java.util.Date" />
<jsp:setProperty name="dateObject" property="time" value="${timeInMilliSeconds}" />
<fmt:formatDate value="${dateObject}" pattern="MMddyyyy HHmm" var="formatedDate" />
Date is: ${formatedDate}