小编Ama*_*rsh的帖子

iPhone Safari拨打电话

我是否可以在HTML页面的代码中添加一些内容,我在iPhone上使用Safari来点击时拨打电话?类似的东西:

<a href="tel://1300111222">click to call</a>
Run Code Online (Sandbox Code Playgroud)

html iphone safari tel

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

在Spring MVC中,捕获数据库异常的位置

在此输入图像描述

我遵循上面建议的结构(http://viralpatel.net/blogs/spring3-mvc-hibernate-maven-tutorial-eclipse-example/).我尝试添加重复条目,这导致以下异常:

SEVERE: Servlet.service() for servlet [appServlet] in context with path [/cct] threw exception [Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: Duplicate entry 'a@b.com' for key 'PRIMARY'; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Duplicate entry 'a@b.com' for key 'PRIMARY'] with root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'a@b.com' for key 'PRIMARY'
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at << removed for readability>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    at com.sun.proxy.$Proxy26.addUser(Unknown Source)
    at com.bilitutor.cct.control.HomeController.signup(HomeController.java:56)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    << …
Run Code Online (Sandbox Code Playgroud)

hibernate exception-handling spring-mvc

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

AngularJS日志JSON

有没有办法输出来自服务器的JSON响应?我正在尝试以下方式,产生不良输出:

$http({ method: 'GET', url: 'getUser' })
        .success(function (data,status) {
            $scope.user = data;
            console.log("User="+data);})
        .error(function (data,status) {
            $scope.status = status;
            if(status==403)
                $location.path( "/" );
        });
Run Code Online (Sandbox Code Playgroud)

输出:

User=[object Object] 
Run Code Online (Sandbox Code Playgroud)

logging json angularjs

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

在开发期间无法使用 Webpack4 访问 %PUBLIC_URL%/favicon.ico

我的 webpack.config.js 和 package.json 如下所示。当我进行构建时,/dist目录确实包含 favicon.ico 。但做的npm run start结果在URIError: Failed to decode param '/%PUBLIC_URL%/favicon.ico'.

目录结构是 在此处输入图片说明



#webpack.config.js

const HtmlWebPackPlugin = require("html-webpack-plugin");
const CopyWebpackPlugin = require('copy-webpack-plugin')

const htmlWebpackPlugin = new HtmlWebPackPlugin({
    template: "./public/index.html",
    filename: "./index.html"
});
const copyWebpackPlugin = new CopyWebpackPlugin([{
    from: './public/favicon.ico',
    to: './favicon.ico'
}]);

module.exports = {
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                use: { loader: "babel-loader" }
            },
            {
                test: /\.css$/,
                use: [ { loader: "style-loader" }, { loader: "css-loader" …
Run Code Online (Sandbox Code Playgroud)

favicon reactjs webpack

7
推荐指数
0
解决办法
4139
查看次数

单页 Web 应用程序、CORS 和安全问题

情况

  1. 我正在编写一个单页 Web 应用程序(使用 Angular)。让我们称之为SPA
  2. 另一个队友正在编写一些 API(使用 Node.js)。让我们打电话是服务器
  3. 我的 SPA 是使用 login/passwd 登录到服务器,然后做一些事情

我的队友决定使用 cookie 来跟踪会话。因此,在成功登录后,将在加载 SPA 的 Web 浏览器中设置一个仅限 http 的 cookie。

问题

如果我们将 SPA 放在服务器的 public_html 目录中,则一切正常。但是,这使 SPA 成为 API 代码的一部分。这打破了我们的构建过程,因为现在每个版本升级到 SPA 也需要升级 API。

如果我们将 SPA 托管在仅提供静态 SPA 文件的单独网络服务器中,我会遇到 CORS 问题。由于 SPA 的来源与其尝试访问的 API 不同,因此浏览器会阻止 ajax 调用。为了克服这个问题,我们必须Access-Control-Allow-Origin在服务器端进行适当的设置。我也明白Access-Control-Allow-Credentials:true需要设置,以指示浏览器设置/发送 cookie。

可能的解决方案

  1. 我们创建了一个构建过程,每次 SPA 升级时都会对服务器的 public_html 目录执行 git-pull。我试图避免这种情况以保持客户端和服务器升级分开。

  2. 我们创建了一种代理类型的情况,其中服务器不存储 SPA 文件,而是从托管 SPA 文件的另一台服务器按需收集它们。在这种情况下,Web 浏览器将看到来自同一来源的 SPA 文件和后续 ajax 调用。

  3. 我们对服务器进行编码以设置Access-Control-Allow-Origin:*其响应。首先,这太开放了,看起来不安全。是真的没有安全感,还是只是我的感觉?此外,由于我们正在设置Access-Control-Allow-Credentials:true,Chrome …

security cookies oauth cross-domain single-page-application

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

Xcode 4.6.1调试器局部变量不可用

我最近将Xcode 4.6升级到4.6.1,我注意到以下异常行为:

  1. 有时,断点时无法使用局部变量

  2. 当在一个断点上暂停时Step Into和Step Over,编辑器突出显示代码的错误行.

对于调试,LLVM 4.2编译器 - COde生成/优化级别设置为"无".我试过清理项目,模拟器等等.没有运气.

有线索吗?

debugging xcode4.6

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

在一个令人满意的不可思议的范围内跨越

我有一个contenteditable div,其中包含几个类dontEdit的跨度.有没有办法让跨度不可分割,而div的其余部分保持可编辑状态.

<div contenteditable=true>
    editable1 <span class="dontEdit">uneditable1</span> editable2
</div>
Run Code Online (Sandbox Code Playgroud)

请看这里的小提琴:http://jsfiddle.net/LZpag/

html contenteditable

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

Websockets 将 byte[] 转换为字符串

我有以下代码:

            Console.WriteLine("New Socket connection opened");
            var buffer = new byte[1024 * 4];
            WebSocketReceiveResult result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
            while (!result.CloseStatus.HasValue)
            {
                Console.WriteLine("New message received : "+ Encoding.UTF8.GetString(buffer));
            }
Run Code Online (Sandbox Code Playgroud)

当我发送Hello我的客户端时,我可以Hello?????????????在控制台上看到。显然,这意味着我有一个 size 的缓冲区1024 * 4,其中的前几个字节由Hello. 我如何处理trim我的字符串(最终,我想将 JSON 从我的客户端传递到服务器)。

.net c# arrays buffer websocket

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

objective c查找字符串的像素宽度

替代文字

我有一个固定宽度的UIButton,我想在其中放置文本.由于String的大小事先是未知的,因此当我从平面文件中读取String时,我将不得不调整字体大小.我怎样才能做到这一点?类似于以下的功能将很棒:

UIFont resizeFontAs:(UIFont)initialFont andStringAs:(NSString*)string andWidthAs:(int)width
Run Code Online (Sandbox Code Playgroud)

提前致谢

编辑:此代码似乎不起作用:

// Method for creating button, with background image and other properties
- (UIButton *) getCallAgentButtonWithTitleAs:(NSString *)aTitle andImageAs:(UIImage*)bgImg atIndex:(int)index{    
    UIButton *aButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];  
    aButton.frame = CGRectMake(10, 2+index*50, 300, 48);    
    aButton.titleLabel.frame = CGRectMake(aButton.titleLabel.frame.origin.x + 25.0,                   aButton.titleLabel.frame.origin.y, aButton.titleLabel.frame.size.width - 50.0,     aButton.titleLabel.frame.size.height);     
    aButton.titleLabel.adjustsFontSizeToFitWidth = YES;
    [aButton setTitle:aTitle forState:UIControlStateNormal];
    //aButton.titleLabel.font = [UIFont boldSystemFontOfSize:12];   
    [aButton setTitleColor:UIColorFromRGB(0xFDD428) forState:UIControlStateNormal];
    [aButton setBackgroundImage:bgImg forState:UIControlStateNormal];
    [aButton addTarget:self action:@selector(callAgent:) forControlEvents:UIControlEventTouchUpInside];
    // set the tag as the index and use it later to obtain the …
Run Code Online (Sandbox Code Playgroud)

size fonts pixel objective-c

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