草庐IT

filter_parameters

全部标签

Java实践: returning same object which was passed as parameter

在下面的代码中,updateWithContex返回它作为参数的同一个对象真的是不好的做法吗?classSomeClass{FooupdateWithContex(Foofoo){foo.setAppId(i);foo.setXId(index);//.....returnfoo;}}classFoo{publicvoidsetAppId(intappId){//}publicvoidsetXId(intappId){//}publicvoidchangeState(Xx){//}}在C++中,我见过这样的代码:BigObject&fastTransform(BigObject&myB

java - JAXB 编码 : Filter values of leaf elements

我有一个相当复杂的JAXB树对象。对于每个叶节点,我需要过滤其实际值例如YogasanaVijnana:theScienceofYogaDhirendraBrahmachari1966此处的叶节点为Title、author和Date。想象一下,我需要为这个JAXB模型编写一个编码文档,每个叶节点的第一个字符都被删除:ogasanaVijnana:theScienceofYogahirendraBrahmachari966什么是最好的方法?我看到了两个起点,但是,我目前卡住了。1。在JAXB模型中进行更改是否有一些遍历机制可以用来获取任何JAXB对象(某种访问者模式或其他)的叶元素?2。

Java 8 map : filter value and throw exception if match found

我正在尝试在Map中查找匹配值,如果找到,我需要抛出IllegalArgumentException。我的代码如下:finalStringstringToBeMatched="someRandomString";map.values().stream().filter(a->stringToBeMatched==a.getField()).findAny().ifPresent(a->thrownewIllegalArgumentException());我在token“throw”上遇到语法错误。我不确定我哪里出错了。 最佳答案

java - SQL异常 : No value specified for parameter 1

我在执行我的应用程序时遇到了以下错误:java.sql.SQLException:Novaluespecifiedforparameter1这是什么意思?我的dao中的UserGroup列表:publicListselect(Integervar){Listug=null;try{conn.Connection();stmt=conn.getPreparedStatement("selectid_usuario,id_grupofromusuarios_gruposwhereid_grupo='"+var+"'");ResultSetrs=stmt.executeQuery();ug=

java - 将 Tomcat 6 移植到 7 : Problem with <filter>

我试图在Tomcat7服务器上部署我的Tomcat6webapp,但是如果我将元素添加到我的web.xml会遇到以下问题:java.lang.NoSuchMethodException:org.apache.catalina.deploy.WebXmladdFilteratorg.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2687)atorg.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2713

java - Spring MVC 和 JSP : How to pass a parameter from the controller to JSP?

我有2个JSP页面,第一个我有输入文本表单,我想显示插入另一个JSP页面的值。(使用SpringMVC)。 最佳答案 将您要传输到下一页的变量放在隐藏字段中(将字段放在相同的表单中,将您带到下一页。然后通过JSTL获取您的参数。这是一个示例:Controller:@RequestMapping(value="/nextPage",method=RequestMethod.POST)publicStringFicheService(@ModelAttributeCMDBeancmd,BindingResultresult,@Reque

java - 支柱 2 : parameters between Actions

我有以下问题:当我完成一个表单并且操作保存表单的值时,我需要传递一个参数(例如ID),这将转发到结果=“成功”并且我需要在成功中调用的操作与ID和其他参数稍后在下一个表单中使用以保存此信息(info-form2和info.form1)...例如:FORM1(用户)====“成功”====>FORM2(地址)userForm.html===================>addressForm.html?user_id=X...(其中X:Id传递了UserAction的抛出(方法:save)到AddressAction(method:newAddress))谢谢你的帮助提前致谢

java - sonarqube 错误地报告 "PreparedStatement has no parameters."

sonarqube错误地报告以下(简化)源PreparedStatement没有参数。(鱿鱼:S2695):publicstaticfinalStringUPDATE_QUERY="UPDATETABLESETCOL1=?WHEREPK=?";privatePreparedStatementpreparedStatement=null;publicvoidupdateMethod(Datedate,Longpk){if(preparedStatement==null){//ConnectionServiceisnotaConnection!preparedStatement=Conne

java - Spring 在 Filter 中使用 @Value 注解

我目前正在开发一个Spring项目,我正在制作一个新过滤器来检查请求中是否发送了有效的JWT。我遇到了一个问题,我无法像这样使用@Value注释从我的application.yml文件中获取值。@Component@Order(2)publicclassJwtConfigurationimplementsFilter{@Value("${jwt.secret}")privateStringjwtSecret;我知道这很好用,因为我在单元测试中有同样的东西。我在某处读到过滤器不在应用程序上下文中,因此它无法访问配置,我将无法Autowiring依赖项。有谁知道从我的application

Java 反射 : Checking the type of the method parameter at runtime

我需要检查方法第一个参数的类型是List>或不。有人能提出比将它与字符串进行比较更好的解决方案吗?Methodm=Foo.class.getMethod("m1",List.class);if(m.getGenericParameterTypes()[0].toString().equals("java.util.List>")){...}我的意思是这样的:List.class.isAssignableFrom((Class)((ParameterizedType)m.getGenericParameterTypes()[0]).getRawType()));检查它是否是一个列表。但是