我正在尝试在字符串数组中的单词之间拆分空格和短划线字符.以下代码显示了我之后的结果.
码:
String[] wordSplit = txtInput.split (" ") && txtInput.split ("-");
Run Code Online (Sandbox Code Playgroud)
输入:
hello world hello-world
Run Code Online (Sandbox Code Playgroud)
预期产量:
there are: 4 word(s) of length 5.
Run Code Online (Sandbox Code Playgroud) 我是一个使用JSP的初学者.我想使用最大范围的用户选择显示递增整数的列表.
输入:6应显示以下内容:
的Input.jsp
<body>
<input type="number" name="numberMax" required>
<input type="submit" value="submit">
</body>
Run Code Online (Sandbox Code Playgroud)
jspResult.jsp
<body>
<%
int numberMax = request.getParameter("numberMax"); // Cannot convert from String to int
%>
for (int i = 1; i <= numberMax; i++)
{ %>
<ul>
<li><%= i %></li>
</ul>
<% } %>
</body>
Run Code Online (Sandbox Code Playgroud)
如何将输入转换为整数以便打印jsp scriptlet.