小编Rom*_*man的帖子

textarea下的额外空间与浏览器不同

在textarea标签下有一些额外的空间.在不同的浏览器中从1到4像素.标记非常简单:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
    <head>
        <style>
            body {
                margin: 0;
                padding: 0;
            }
            .main {
                background-color: red;
            }
            textarea {
                background-color: gray;
                resize: none;
                margin: 0;
                border: 0 none;
                padding: 10px;
                height: 50px;
                overflow: hidden;
            }
        </style>
    </head>
    <body>
        <div class="main">
            <textarea></textarea>
        </div>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

以下是它在浏览器中的呈现方式:

截图

为什么会这样?如何删除这个额外的空间?

html css whitespace cross-browser removing-whitespace

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

EF Code First 5.0.rc迁移不会更新Identity属性

比如,我们正在使用EF Code First,我们有这个简单的模型:

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace EFCodeFirstIdentityProblem.Models
{
    public class CAddress
    {
        public int ID { get; set; }

        public string Street { get; set; }
        public string Building { get; set; }

        public virtual CUser User { get; set; }
    }

    public class CUser
    {
        public int ID { get; set; }

        public string Name { get; set; }
        public string Age { get; set; }

        [Required]
        public virtual …
Run Code Online (Sandbox Code Playgroud)

entity-framework ef-code-first ef-migrations

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

Json.encode特殊符号\ u003c MVC3

我有JavaScript应用程序,我使用客户端模板(underscore.js,Backbone.js).

初始页面加载的数据被绑定到页面中(.cshtml Razor-file):

<div id="model">@Json.Encode(Model)</div>
Run Code Online (Sandbox Code Playgroud)

Razor引擎执行转义,如果Model是的话

new { Title = "<script>alert('XSS');</script>" }
Run Code Online (Sandbox Code Playgroud)

,在输出中我们有:

<div id="model">{&quot;Title&quot;:&quot;\u003cscript\u003ealert(\u0027XSS\u0027)\u003c/script\u003e&quot;}</div>
Run Code Online (Sandbox Code Playgroud)

其中"解析"后的操作:

var data = JSON.parse($("#model").html());
Run Code Online (Sandbox Code Playgroud)

我们有完整的"Title"字段对象数据"<script>alert('XSS');</script>"!

当这转到下划线模板时,它会发出警报.

不知何故,\u003c-像符号被视为正确的" <"符号.

我如何逃脱" <"符号&lt;,并&gt;从数据库(如果他们莫名其妙地到了那里)?

也许我可以调整Json.Encode序列化以逃避这些符号?也许我可以设置Entity Framework我正在使用的,以便在从DB获取数据时始终自动地逃避这些符号?

javascript asp.net-mvc json escaping

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

在服务器和客户端之间共享mustache/nustache模板.ASP.NET MVC

我在客户端使用mustache.js,在ASP.NET MVC3项目中使用Nustache.

Person.mustache在服务器上的View文件夹中有模板,我使用如下:

@Html.Partial("Person")
Run Code Online (Sandbox Code Playgroud)

来自Razor主视图(Index.cshtml).

但是如何将其转移到客户端?浏览器无权访问Views文件夹以获取模板的原始内容.不知何故,我必须有一种方法来包含在服务器上输出Person.mustache模板的HTML原始文本.如果我从Razor视图中需要它,它会编译它,因为它是普通的服务器模板引擎.

请有人能提出任何想法吗?谢谢.

ajax asp.net-mvc templates razor mustache

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

如何在Spring MVC应用程序中显示上传的图像

我有Spring MVC应用程序,我想将用户图像上传到resources/uploads文件夹中.显然,我想在我的网站上提供服务.但是当我试图sample.png放入resources文件夹时,仅仅是出于测试目的,网络服务器回答了"not found".我重新建立项目和图片变得可访问.我删除了图片,它仍然可以访问.我重新构建项目和服务器应答它应该("未找到").

这个奇怪的行为是什么?资源是否被构建到最终的jar文件中?这是否意味着,在重建项目之前,所有上传的用户图片都无法访问?如果是这样,我完全不应该将上传的文件放到资源文件夹中,那么我应该在哪里放置它们?为什么会这样,我该如何服务这些照片?

非常感谢你.

context.xml中:

<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->

    <!-- Enables the Spring MVC @Controller programming model -->
    <annotation-driven>
        <message-converters>
          <beans:bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
              <beans:property name="objectMapper" ref="customObjectMapper"/>
          </beans:bean>
      </message-converters>
    </annotation-driven>

    <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
    <resources mapping="/resources/**" location="/resources/" />


    <!-- mustache.java -->
    <beans:bean id="viewResolver" class="org.springframework.web.servlet.view.mustache.MustacheViewResolver">
        <beans:property name="cache" value="false" />
        <beans:property name="prefix" …
Run Code Online (Sandbox Code Playgroud)

spring spring-mvc

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

未找到符号:Google VR SDK中的_UnityGetAudioEffectDefinitions

这是我在XCode iPhone 5S模拟器中尝试运行Unity3D项目(Sample Treasure Hunter)时遇到的错误.

dyld: Symbol not found: _UnityGetAudioEffectDefinitions
   Referenced from: /Users/romanmac/Library/Developer/CoreSimulator/Devices/333B47B5-B6BC-41E4-BD6D-611A9B4CE1DA/data/Containers/Bundle/Application/D8B8D3EF-F872-42F8-8407-3EC20B13474E/ProductName.app/ProductName
   Expected in: flat namespace
  in /Users/romanmac/Library/Developer/CoreSimulator/Devices/333B47B5-B6BC-41E4-BD6D-611A9B4CE1DA/data/Containers/Bundle/Application/D8B8D3EF-F872-42F8-8407-3EC20B13474E/ProductName.app/ProductName
 (lldb) 
Run Code Online (Sandbox Code Playgroud)

在设备上它工作正常.

Unity 5.4.0f3个人Xcode 7.3.1(7D1014)

以下是iOS播放器的设置:

在此输入图像描述

在此输入图像描述

我该如何解决这个问题?

unity-game-engine google-vr

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

从根请求调用区域控制器

我的ASP.NET MVC3应用程序中有一些区域:

namespace MyProject.Areas.myarea
{
    public class myareaAreaRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get
            {
                return "myarea";
            }
        }

        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "myarea_default",
                "myarea/{controller}/{action}/{id}",
                new { action = "Index", id = UrlParameter.Optional }
            );
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这个区域包含"Hello"控制器,带有"Smile"动作.

在整个项目的global.asax文件中,我有:

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Default", 
            "{controller}/{action}/{id}", 
            new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );

    }

    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();

        RegisterGlobalFilters(GlobalFilters.Filters);
        RegisterRoutes(RouteTable.Routes);
    }
Run Code Online (Sandbox Code Playgroud)

所以,当我请求"localhost/myarea/hello/smile"时,它按预期调用适当的控制器.

但!当我请求"localhost/hello/smile"时,它会调用hello控制器STILL!有了它,它会查找不在myarea/Views文件夹中的Views,而是在〜/ …

asp.net-mvc-routing asp.net-mvc-areas asp.net-mvc-3

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

jQuery.unbind删除使用$ .proxy创建的错误处理程序

我有JavaScript类:

<html>

<head>
    <script src="MicrosoftAjax.js" type="text/javascript"></script>
    <script src="jquery-1.6.4.min.js" type="text/javascript"></script>

</head>

<body>

<script type="text/javascript">

var ClientControl = function () {
    //some instance-specific code here
};

ClientControl.prototype = {
    initialize: function () {
        this.documentClickedDelegate = $.proxy(this.documentClicked, this);
        //this.documentClickedDelegate = Function.createDelegate(this, this.documentClicked); // from MicrosoftAjax
    },

    bind: function() {
        $(document).bind("click", this.documentClickedDelegate);
    },

    unbind: function() {
        $(document).unbind("click", this.documentClickedDelegate);
    },

    documentClicked: function() {
        alert("document clicked!");
    }
};

var Control1 = new ClientControl();
Control1.initialize();
var Control2 = new ClientControl();
Control2.initialize();

Control1.bind();
Control2.bind();

Control1.unbind();
//Control2`s documentClickedDelegate handler, …
Run Code Online (Sandbox Code Playgroud)

javascript jquery javascript-events microsoft-ajax

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

返回派生类实例的基类的扩展方法

我有一个课程heirarсhy:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MyProject.Models;
using MyProject.Extensions;

namespace MyProject.Models
{
    public abstract class Vehicle
    {
        public string Color { get; set; }
    }

    public class Car : Vehicle
    {
        public int Mileage { get; set; }
    }

    public class Boat : Vehicle
    {   
        public int Displacement { get; set; }
    }

}


namespace MyProject.Extensions
{
    public static class VehicleExtensions
    {
        public static IEnumerable<Vehicle> FilterByColor(this IEnumerable<Vehicle> source, string color)
        {
            return source.Where(q => …
Run Code Online (Sandbox Code Playgroud)

c#

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