我尝试使用setter设置值但是null来了.请帮助我,并给出一些其他更好的方法来做.
import org.apache.commons.beanutils.BeanUtils;
public class TestSetter {
public static void main(String args[]) throws Exception
{
Test t = new Test();
BeanUtils.setProperty(t,"te","teval");
System.out.println("tevalue :"+t.getTe());
}
}
class Test
{
String te;
public String getTe() {
return te;
}
public void setTe(String te) {
this.te = te;
}
}
Run Code Online (Sandbox Code Playgroud)
例外:
Exception in thread "main" java.lang.reflect.InvocationTargetException: Cannot set te
at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1025)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:313)
at test.reflection.TestSetter.main(TestSetter.java:10)
Caused by: java.lang.NoSuchMethodException: Property 'te' has no setter method
at org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:1746)
at org.apache.commons.beanutils.PropertyUtilsBean.setNestedProperty(PropertyUtilsBean.java:1648)
at org.apache.commons.beanutils.PropertyUtilsBean.setProperty(PropertyUtilsBean.java:1677)
at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1022)
... …Run Code Online (Sandbox Code Playgroud) 我的问题很简单,但我很困惑,请帮助我.
在JSP中,我从Servlet1接收一个Attribute(idsList),我想将此Attribute(idsList)发送到另一个servlet,Servlet2,但我可以使用session.setAttribute().我的麻烦是,我们如何在JSP本身发送给Servlet2?
这是我的代码,但它不起作用,因为相同的请求用于设置和获取.请帮忙.
在Servlet1中:
request.setAttribute("idsList",idsList);---is null
Run Code Online (Sandbox Code Playgroud)
在JSP中
List<Integer> idsList =(List<Integer>)request.getAttribute("idsList");
System.out.println("size of ids list :"+idsList.size());
request.setAttribute("idsList",idsList);
Run Code Online (Sandbox Code Playgroud)
在Servlet2中:
request.getAttribute("idsList");---is null
Run Code Online (Sandbox Code Playgroud) 请帮助我找到有效的方法来查找数字字符串.
String str ="-100000.000";
System.out.println(str.matches("-?\\d+(\\.\\d+)?"));
Run Code Online (Sandbox Code Playgroud)
它工作得很完美,但我想接受像这样的数字字符串
String length must be maximum (10,3)--- Example 1234567890.999
String length must be minmum (1)------0
Numeric String must be positive.
valid Numeric Strings(2.333 1878.12 787 989.0)
Run Code Online (Sandbox Code Playgroud) 这里有人员和地址表.有些人可能有地址.如果他们有地址则需要加入地址表,否则无需加入.请帮助解决此案.
select p.name,nvl(a.address,'address not available') from person p,address a
where p.id = 2 and case
when p.addid is not null
then p.addid = a.id
else 0=0 end
Run Code Online (Sandbox Code Playgroud) 如何从转换正则表达式
^((19|20)\\d\\d)(0?[1-9]|1[012])(0?[1-9]|[12][0-9]|3[01])? for 1900-2099
Run Code Online (Sandbox Code Playgroud)
上面的一个完美地工作,只需要更改日期格式1900-9999。所以选择下面的一个。
我这样尝试过
^(([19-99])\\d\\d)(0?[1-9]|1[012])(0?[1-9]|[12][0-9]|3[01])? for 1900-9999
Run Code Online (Sandbox Code Playgroud)
有什么问题,请引导我解决。
我想在其上添加带有字符的超赞字体,但这样做失败。请帮助了解发生了什么问题。
输出:

尝试过的代码:
<i class="fa fa-square fa-2x" style="color:red;"><span style="text-color:white;">S</span></i>
<i class="fa fa-square fa-2x" style="color:yellow;"><span style="text-color:white;">XL</span></i>
<i class="fa fa-square fa-2x" style="color:green;"><span style="text-color:white;">XXL</span></i>
Run Code Online (Sandbox Code Playgroud) 我有 ssns 列表Users(id,ssn,name)和 ids 列表的列表,需要转换为 ssns 列表和 id 列表的映射。你能帮忙解决这个问题吗?
List.of(new User(1, "ssn1", "user1"), new User(2, "ssn2", "user2"), new User(3, "ssn3", "user3"))
Run Code Online (Sandbox Code Playgroud)
Map with 2 keys("SSNs","IDs") and list as value
"SSNs" - List("ssn1","ssn2","ssn3")
"IDs" - List(1,2,3)
Run Code Online (Sandbox Code Playgroud)
public class Test {
public static void main(String[] args) {
List<User> users = List.of(new User(1, "ssn1", "user1"), new User(2, "ssn2", "user2"),
new User(3, "ssn3", "user3"));
Map<String, List<Object>> userMap = users.stream().collect(Collectors.groupingBy(User::getSsn));
}
}
class User {
public int getId() {
return id;
} …Run Code Online (Sandbox Code Playgroud) 请帮助获取调用此页面的当前URL?这有什么问题?,因为警报空洞.
<html>
<head>
<script>
function check()
{
alert(document.referrer);
}
</script>
</head>
<body onload="check()">
</body>
</html>
Run Code Online (Sandbox Code Playgroud) java ×5
regex ×2
css ×1
font-awesome ×1
html ×1
java-stream ×1
javascript ×1
jsp ×1
oracle ×1
reflection ×1
servlets ×1
sql ×1