小编Geo*_*mas的帖子

在jquery数据表中显示之前,将json日期格式化为mm/dd/yy格式

我想在显示一些数据的数据表,我使用的表脚本

$('#userData').dataTable({

        "ajax": {
                "url": "${rc.getContextPath()}/module/roles/users-list",
                "dataSrc":  "",
                },

        "columns":[
        {"data": "userId"},
        {"data": "applicationId"},
        {"data": "username"},
        {"data": "firstName"},
        {"data": "userCreated"},
        {"data": "createdTime"},
        {"data": "updatedTime"}
        ],

     });
Run Code Online (Sandbox Code Playgroud)

表格收到的数据是json,就像是

[
 {  
      "userId":179,
      "applicationId":"pgm-apn",
      "username":"collaborator.user3",
      "password":"password1",
      "email":"user@xample.com",
      "firstName":"Anthony",
      "lastName":"Gonsalves",
      "enabled":true,
      "userCreated":"sitepmadm",
      "userModified":"sitepmadm",
      "createdTime":1422454697373,
      "updatedTime":1422454697373
   },
   {  
      "userId":173,
      "applicationId":"pgm-apn",
      "username":"consumer.user",
      "password":"password1",
      "email":"test@egc.com",
      "firstName":"sherlock ",
      "lastName":"homes",
      "enabled":true,
      "userCreated":"sitepmadm",
      "userModified":"sitepmadm",
      "createdTime":1422010854246,
      "updatedTime":1422010854246
   }
Run Code Online (Sandbox Code Playgroud)

我想将日期显示为正确的日期时间.目前它在json数据中显示为相同的sting.有没有办法在数据表中转换它

jquery json date datatables

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

如何将包含单引号的字符串保存到PostgreSQL中的文本列

我使用hibernate和PostgreSQL作为Smartwcm Web应用程序SDK中的数据库.我在其中一个表中有一个字段,其数据类型是文本.当我尝试使用相应的POJO使用hibernate将值插入表中时,如果我尝试保存到数据库中的String包含,则抛出异常 '.

异常消息是:

Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: Could not execute JDBC batch update; SQL [update public.slider_group set slid_grou_title=?, slid_grou_short_desc=?, site_id=?, status=?, update_date=?, no_slide=?, pos_type=?, widget_type=?, custom_html=?, widget_url=? where slid_grou_id=?]; nested exception is org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
Run Code Online (Sandbox Code Playgroud)

我对应表的java对象是:

 public class WidgetContentTo
        {
            private int             widgetContentId;
            private int     siteId;
            private String      widgetContentName;
            private String      widgetContentShortDesc;
            private int             noWebcontents;
            private String      status;
            private Timestamp   timeCreated;
            private Timestamp   updateDate;
            private String      posType;
            private String      widgetType;
            private …
Run Code Online (Sandbox Code Playgroud)

java sql postgresql orm hibernate

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

上传使用cropper.js插件裁剪的图像

我在我的应用程序中使用了cropper.js插件来裁剪图像.我可以裁剪图像.现在我正在尝试上传图片而不是下载它们.我更新了显示裁剪图像的模态窗口,如下所示:

<!-- Show the cropped image in modal -->
<div class="modal fade docs-cropped" id="getCroppedCanvasModal" aria-hidden="true" aria-labelledby="getCroppedCanvasTitle" role="dialog" tabindex="-1">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="getCroppedCanvasTitle">Cropped</h4>
      </div>
      <div class="modal-body"></div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal" style = "float: left;">Close</button>
       <form class="form-inline" id="croperImgForm" role="form" method="post" action="${rc.getContextPath()}/module/simplewebcontent/save-image" enctype="multipart/form-data">
        <label class="checkbox-inline">
        <input type="checkbox" id="inlineCheckbox1" value="option1"> Save Image
        </label>
        <label class="checkbox-inline">
          <input type="checkbox" id="inlineCheckbox2" value="option2">Save Thumbnail
        </label>
        <button type="submit" class="btn btn-primary" id="svImg" style = "margin-left: …
Run Code Online (Sandbox Code Playgroud)

jquery spring-mvc html5-canvas

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

在tomcat 8的共享文件夹中添加属性文件,并在Spring MVC Web应用程序中使用它

我有一个Java Spring MVC Web应用程序.我使用application.properties文件来设置一些属性值.现在我试图让属性独立于war文件.我在tomcat下创建了一个新的文件夹shared/classes,如下所示.

夹

catalina.properties我添加的文件中shared.loader=${catalina.base}/shared/classes.

在我的root-context.xml文件中,我补充道

<context:property-placeholder location="file:${catalina.base}/shared/classes/application.properties"/>
Run Code Online (Sandbox Code Playgroud)

但是我收到以下错误:

ERROR o.s.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: E:\projects\smartwcm\workspace-20163101-eclipse-wp\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\shared\classes\application.properties (The system cannot find the path specified)
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

java tomcat spring-mvc

4
推荐指数
1
解决办法
2248
查看次数

我们可以在tomcat的server.xml文件中包含文件来配置虚拟主机吗

我的 tomcat 中有该文件的以下部分 server.xml

<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
       prefix="localhost_access_log" suffix=".txt"
       pattern="%h %l %u %t &quot;%r&quot; %s %b" />

</Host>

<Host name="mydomain1"  appBase="d1"
    unpackWARs="true" autoDeploy="true">
    <Alias>xyz-mydomain1.com</Alias>
    <Alias>abc.mydomain1.com</Alias>


<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
       prefix="d1_access_log" suffix=".txt"
       pattern="%h %l %u %t &quot;%r&quot; %s %b" />

</Host>

<Host name="mydomain2"  appBase="d2"
    unpackWARs="true" autoDeploy="true">


<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
       prefix="d2_access_log" suffix=".txt"
       pattern="%h %l %u %t &quot;%r&quot; %s %b" />

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

有什么方法可以通过使用一些 xml 文件的 include 选项来包含额外的主机条目,这些文件可以放置在我的 tomcat 的 conf 文件夹中。

virtualhost server.xml tomcat8

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

如何在spring security authenticated登录中获取用户输入的用户名和密码值

我在我的应用程序中使用Spring MVC,登录通过spring security进行身份验证.我的类中有以下两种方法UserServiceImpl.java,public UserDetails loadUserByUsername(String userName)抛出UsernameNotFoundException,DataAccessException {

        ApplicationTO applicationTO = null;
        try
            {
                applicationTO = applicationService.getApplicationTO(adminDomainName);
            }
        catch (ApplicationPropertyException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        UserTO userTO = getUserTO(applicationTO.getApplicationId(), userName);
        if (userTO == null)
            {
                throw new UsernameNotFoundException("user not found");
            }
        httpSession.setAttribute("userTO", userTO);
        return buildUserFromUserEntity(userTO);
    }


User buildUserFromUserEntity(UserTO userTO)
            {
                String username = userTO.getUsername();
                String password = userTO.getPassword();
                int userId = userTO.getUserId();
                int applicationId = userTO.getApplicationId();
                boolean enabled = userTO.isEnabled();
                boolean accountNonExpired = true;
                boolean …
Run Code Online (Sandbox Code Playgroud)

java security spring spring-mvc spring-security

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

读取保存到 SES 中 s3 存储桶的传入电子邮件

我已经配置了AWS SES发送和接收电子邮件,我已经验证了我的域并创建了规则集,所有传入的电子邮件现在都将存储在S3 bucketwith object key prefix as email. 我发现以下代码用于从 S3 存储桶读取文件: http://docs.aws.amazon.com/AmazonS3/latest/dev/RetreeringObjectUsingJava.html

我正在尝试阅读电子邮件。我的 SES 规则将所有传入电子邮件存储到我指定的 s3 存储桶中。我正在尝试添加读取存储桶、获取电子邮件的代码。下次当我读取该存储桶时,我如何才能了解之前读取了哪些电子邮件以及要读取哪些电子邮件。那么有什么方法可以让我读取带有电子邮件的存储桶,并将它们设置为已读,这样我就不必再次处理它们

amazon-s3 amazon-web-services amazon-ses

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

如何比较时间戳是否落在 Java 中给定时间段的范围内

在我的 Java Spring MVC Web Application,我正在尝试编写一个程序来保存一些带有时间戳的数据。但是我有一个我必须排除的特定时间段。

例如,我有以下时间戳: Sat Jul 28 17:03:00 IST 2018这是一个 Java 日期对象。在保存到数据库之前,我必须检查这个时间是否在指定范围内,如果我必须在时间范围结束后获得下一分钟。

但时间范围是以下格式的字符串:

String startTime =  "5:03 PM";
String endTime = "5:10 PM";
Run Code Online (Sandbox Code Playgroud)

因此,如果我的 timeStamp 介于这段时间之间,则我的时间戳应更新为Sat Jul 28 17:11:00 IST 2018.

我现在正在寻找比较两个时间值的方法,因为一个是字符串,另一个是时间戳。

有什么办法可以转换吗String endTime = "5:10 PM"?到Sat Jul 28 17:11:00 IST 2018或只是比较的部分时间,计算出分的区别,并添加到时间戳。

java calendar jodatime

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

Javascript将JSON字符串转换为数组数组

我正在尝试使用以下数据转换JSON字符串:

{
    "locations": [{
        "info": "7811 N. Octavia",
        "longitude": -87.8086439,
        "latitude": 42.0229656
    }, {
        "info": "PO Box 271743",
        "longitude": -73.087749,
        "latitude": 41.6032207
    }, {
        "info": "P.O. Box 269",
        "longitude": -86.7818523,
        "latitude": 34.0667074
    }]
}
Run Code Online (Sandbox Code Playgroud)

改为以下结构:

var locations = [
    ['Bondi Beach', -33.890542, 151.274856],
    ['Coogee Beach', -33.923036, 151.259052],
    ['Cronulla Beach', -34.028249, 151.157507],
    ['Manly Beach', -33.80010128657071, 151.28747820854187],
    ['Maroubra Beach', -33.950198, 151.259302]
];
Run Code Online (Sandbox Code Playgroud)

有什么方法可以使用javascript来实现吗?

javascript arrays json

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

在Java中将美元转换为美分的最准确方法是什么

在Java中,将Double值的Dollar转换为cents的美分的最佳方法是什么。目前,我使用以下方法:

Double cents = new Double(dollar*100);
int amount = cents.intValue();
Run Code Online (Sandbox Code Playgroud)

这种方法有多精确?有没有更好的方法可以做到这一点。

java double currency

-2
推荐指数
1
解决办法
2979
查看次数