小编car*_*ruk的帖子

在空格上拆分字符串或仅划线.Java Applet

我正在尝试在字符串数组中的单词之间拆分空格和短划线字符.以下代码显示了我之后的结果.

码:

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)

java regex applet split

3
推荐指数
1
解决办法
5407
查看次数

将String转换为Integer JSP

我是一个使用JSP的初学者.我想使用最大范围的用户选择显示递增整数的列表.

输入:6应显示以下内容:

  • 1号
  • 2号
  • 3号
  • 4号
  • 5号
  • 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.

html java jsp scriptlet

2
推荐指数
1
解决办法
6万
查看次数

标签 统计

java ×2

applet ×1

html ×1

jsp ×1

regex ×1

scriptlet ×1

split ×1