Struts2学习笔记-jsp中引用struts2框架

时间:2021-01-20 14:47:16

如果在jsp中需要引用struts2 框架,需在前面加上以下内容

    <%@taglib prefix="s" uri="/struts-tags" %>

taglib代代表引入库,uri是库的位置,prefix代表会在下文中使用的时候,以什么的前序为开头,下面是一个例子

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<center>
<s:property value="popedom" />
<br /> <b>User Login</b><br />
<s:form>
<s:textfield label="Login User" name="userName"></s:textfield>
<s:password label="Password" name="passwrod"></s:password>
<s:submit value="submit"></s:submit>
</s:form> </center>
</body>
</html>