Jsp语法及指令
jsp语法
- JSP声明
- JSP 脚本
- JSP 表达式
<% ! String a;%>
1.定义变量
- <% JAVA 程序;%>
<%
int num=5;
long fac(int n){
long f =1;
for(int i=1;i<=n;i++)
{
f=f*i;
} return f;
}
%>
- <% = 表达式 %> 输出值
<% =str %>
jsp指令
<$@include file="被包含的文件"$><%@page [language="java"]%> 定义全局属性
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<%
int num=5;
long fac(int n){
long f =1;
for(int i=1;i<=n;i++)
{
f=f*i;
} return f;
}
%>
<body>
<form id="form1" name ="form1" method="post" action="getparameter.jsp">
账号:<input name="uid" type="text id="uid" />
密码: <input name="upw" type="password" id="upw" />
<input tyep="submit" name="Submit" value="提交" />
</form>
<%
String str="wors";
str=str+",China!";
%>
<%=str%>
<% num %>的阶乘是:<%= fac(num)%>
</body>
<html>
转载自:https://segmentfault.com/a/1190000042018658