当前位置:   article > 正文

JSP EL表达式

JSP EL表达式

作文提交
index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>

<form action="deal.jsp" method="post">
	<textarea cows="5" cols="100" name="zuowen"></textarea>
	<input type="submit">
</form>

</body>
</html>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

deal.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="/stringDeal" prefix="sd" %>
<% request.setCharacterEncoding("utf-8"); %>>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>

提交的信息是:
${sd:shiftEnter(param.zuowen)}

</body>
</html>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

stringDeal.tld

<taglib version="2.0">
<tlib-version>1.0</tlib-version>
<uri>/stringDeal</uri>
<function>
<name>shiftEnter</name>
<function-class>zzy.StringDeal</function-class>
<function-signature>java.lang.String shiftEnter(java.lang.String)</function-signature>
</function>
</taglib>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

StringDeal.java

package zzy;

public class StringDeal {
	public static String shiftEnter(String o){
		String n=o.replaceAll("\r\n", "<br>");
		n=n.replaceAll(" ", "&nbsp");
		return n;
	}
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/46427
推荐阅读
相关标签