我是 JSTL 世界的新手,所以请对我温柔一点,我已经在阅读但找不到解决方案。
我想从输入框的开头和结尾修剪空格,因此当用户单击提交按钮时,我的控制器会收到不带空格的字符串。
请不要建议我使用其他框架,因为我已经遇到了这个问题,当我掌握了这个,我会进入下一步。
这是我的 JSP 代码,我试过了,但没有用,似乎上下文没有保留我传递的值,之后我只是在尝试......任何帮助表示赞赏!
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!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">
<LINK REL=StyleSheet HREF="resources/index-style.css" TYPE="text/css">
<title>Submit a new academic!</title>
</head>
<div class="home">
<a href="index"><img src="resources/home.png" /></a>
</div>
<div class="list">
<h1>This is the place where you register a new Academic on the
system!</h1>
</div>
<p></p>
<div class="list">
<form action="addAcademicAction" method="post">
<p>Submit your name:</p>
<input type="text" name="academicName"><br>
<p>Level of education</p>
<input type="radio" name="educationLevel" value="student" checked>Student<br>
<input type="radio" name="educationLevel" value="csstudent">Computer
Science Student<br> <input type="radio" name="educationLevel"
value="professor">Professor<br> <br>
<button name="submit" type="submit" value="HTML">Add
Academic!</button>
</form>
</div>
<c:if test="${context.request.method=='POST'}">
<c:set var="academicName" value="${fn:trim(param.academicName)}"/>
</c:if>
<body>
</body>
</html>