小编Rag*_*dra的帖子

条件检查包含对象的列表中是否存在值,

我试图编写一个if条件来检查包含许多对象的列表中是否存在一个值,这是我的代码:

List<TeacherInfo> teacherInfo=ServiceManager.getHelperService(TeacherManagementHelper.class, request, response).getTeacherInfoId();
if(teacherInfo.contains(inputParam))
{
    out2.println("<font color=red>");
    out2.println("Id Not Available");
    out2.println("</font>");
 }
 else
 {
    out2.println("<font color=green>");
    out2.println("Id Available");
    out2.println("</font>");        
 }
Run Code Online (Sandbox Code Playgroud)

执行第一句后getTeacherInfoId()方法成功返回一个对象列表,在那些对象中我要检查任何对象的值是否相同inputParam.我上面的代码是对的吗?如果有错,请帮助我.

java list

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

单击动画Glyphicon

我试图动画一个glyphicon-refresh图标,以便当我点击图标时它应该旋转.我试图使用CSS3这样做,但它无法正常工作.

这是我的标记:

<a id="update" href="#"><i class="glyphicon glyphicon-refresh"></i></a>
Run Code Online (Sandbox Code Playgroud)

这是我的css:

<style>

.glyphicon-refresh-animate {
  animation-name: rotateThis;
  animation-duration: .5s;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}

@keyframes "rotateThis" {
 from { transform: scale( 1 ) rotate( 0deg );   }
 to   { transform: scale( 1 ) rotate( 360deg ); }
}

</style>
Run Code Online (Sandbox Code Playgroud)

这是我的JS:

<script type="text/javascript">
    $( document ).ready( function() {
        $( "#update" ).on( "click", function( e ) {
            var $icon = $( this ).find( ".glyphicon glyphicon-refresh" ),
            animateClass = "glyphicon-refresh-animate";

            $icon.addClass( animateClass );
            // setTimeout …
Run Code Online (Sandbox Code Playgroud)

javascript css jquery css3 twitter-bootstrap

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

如何使用Apache Commons BeanUtils设置日期类型值,

我有一个HTML表单enctype="multipart/form-data"。我有一个dto它拥有所有类settergetters。由于我要以多部分形式提交表单,getParameter()因此无法使用我使用Apache Commons BeanUtils来处理html表单字段的方法。我的servlet如下

List<FileItem> items = (List<FileItem>) new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request);
for (FileItem item : items) {
if (item.isFormField()) {
// Process regular form field (input type="text|radio|checkbox|etc", select, etc).
String fieldname = item.getFieldName();
String fieldvalue = item.getString();
System.out.println(fieldname);
System.out.println(fieldvalue);
// ... (do your job here)
//getters and setters
try {if((!fieldname.equals("dob"))&&(!fieldname.equals("doj"))){
             BeanUtils.setProperty(teacherInfo, fieldname, fieldvalue);}
} catch (IllegalAccessException e) {
    e.printStackTrace();
} catch (InvocationTargetException e) {
    e.printStackTrace();
}

} else {

        //Code for …
Run Code Online (Sandbox Code Playgroud)

java servlets file-upload apache-commons-beanutils

0
推荐指数
1
解决办法
3985
查看次数

如何使用if else语句打印"Hello World"

我准备采访,所以在互联网的某个地方,我得到了这个:

什么应该是"条件",以便下面的代码片段打印"HelloWorld"?

if(<condition>)
  printf ("Hello");
else
  printf("World");
Run Code Online (Sandbox Code Playgroud)

请帮帮我.

c

-8
推荐指数
1
解决办法
4574
查看次数