小编Mat*_*aug的帖子

$ _POST最大数组大小

我有一个超过1000个元素的非常大的形式.它们已经嵌套在表单html结构中

                {foreach from=$result item=item}
                    <tr>
                        <td><input type="text" value="{$item.receiver.name}" name="item[{$item.id}][receiver][name]" /></td>
                        <td><input type="text" value="{$item.receiver.account_number}" name="item[{$item.id}][receiver][account_number]" /></td>
                        <td><input type="text" value="{$item.receiver.bank_code}" name="item[{$item.id}][receiver][bank_code]" /></td>
                        <td><input type="text" value="{$item.amount}" name="item[{$item.id}][amount]" /></td>
                        <td><input type="text" value="{$item.usage.first}" name="item[{$item.id}][usage][first]" /></td>
                        <td><input type="text" value="{$item.usage.second}" name="item[{$item.id}][usage][second]" /></td>
                        <td><input type="text" value="Yourdelivery GmbH" name="item[{$item.id}][usage][third]" /></td>
                        <td>
                            <input type="checkbox" value="1" name="item[{$item.id}][import]" />
                        </td>
                    </tr>
                {/foreach}
Run Code Online (Sandbox Code Playgroud)

它是为大规模银行交易创建一个DATAUS文件.但是在达到1000多行之后,不再向$ _POST数组添加元素,并且调试器显示以下元素计数.

Xdebug输出

我已经将max_post_size添加到100M进行测试,但没有任何帮助.

php arrays post

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

无论请求的URL是什么,都将任何CDN配置为仅提供一个文件

我目前正在开发一个新项目,整个页面应该在HTML5/JS中实现,而不是API/JSON.由于整个应用程序应该只包含一个HTML文件(index.html)和一个JS MVC应用程序(可能是backboneJs),我正在考虑SEO和用户友好的URL.

在那里我遇到了

window.document.pushstate('','title','/url');
Run Code Online (Sandbox Code Playgroud)

借助该html5功能,我可以定义URL而无需真正离开或重新加载页面.但是...... 出于性能原因和低费用,我想将应用程序部署到像Amazon CloudFount这样CDN中.我不需要任何服务器基础设施(当然除了我需要的API)

因此,无论调用什么URL,我都可以配置CDN(实际上是任何类似AWS,Azure,Akamai的CDN)来提供相同的HTML文件

http://www.example.com =>发送index.html

http://www.example.com/any_subpage =>发送index.html

等等 ...

您可以在http://html5.gingerhost.com找到一个工作示例.但该页面的创建者可能会使用.htaccess文件或熟悉的东西将所有内容映射到同一文件.我想在CDN中提供相同的功能.

javascript seo html5 cdn amazon-web-services

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

使用HTTP和REGEX进行清漆清洗

我想使用HTTP清除我的清漆元素.此http调用是从清漆本身后面的后端服务器触发的,因此后端服务器除了HTTP之外没有其他访问权限.

我已经使用相应的ACL实现了以下清除规则,它可以正常工作

curl -X PURGE http://www.example.com/image/123/photo-100-150.jpg
Run Code Online (Sandbox Code Playgroud)

但我希望能够使用Regex通过HTTP清除URL

curl -X PURGE http://www.example.com/image/123/*.jpg
Run Code Online (Sandbox Code Playgroud)

这样我想在上传新内容后清除此图像的所有缩放版本.有办法吗?

curl varnish purge

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

Spring MVC testframework因HTTP Response 406而失败

我开始使用Spring 3.2的新MVC Testframework,并且无法为我的所有测试用例获取406个HTTP响应代码.

测试用例很简单

public class LocationResouceTest {

    @Autowired
    private WebApplicationContext wac;

    private MockMvc mockMvc;

    @Before
    public void setup() {
        this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
    }

    @Test
    public void testGetLocationByPlzPattern() throws Exception {
        // here I need to define the media type as a static var from MediaType
        this.mockMvc.perform(get("/someurl?someparam=somevalue")).andExpect(status().isOk());
    }

}
Run Code Online (Sandbox Code Playgroud)

相应的资源是

@Controller
// here I need to define the media type as string
@RequestMapping(value = "/someurl", produces = "application/json; charset=UTF-8")
public class LocationResource {

    @ResponseBody
    @RequestMapping(method = RequestMethod.GET)
    public ArrayList<DTO> getAllIndex(@RequestParam("someparam") …
Run Code Online (Sandbox Code Playgroud)

java testing model-view-controller spring

9
推荐指数
2
解决办法
9958
查看次数

将来自RabbitMQ的消息转换为string/json

我目前正在努力解决一个公平的问题.我想从RabbitMQ收到一条消息,并将其转换为字符串(或稍后的json对象).但我得到的只是字节数.

消息对象显示本身作为一个字符串,方式

(Body:'{"cityId":644}'; ID:null; Content:application/json; Headers:{}; Exchange:; RoutingKey:pages.type.index; Reply:null; DeliveryMode:NON_PERSISTENT; DeliveryTag:1)
Run Code Online (Sandbox Code Playgroud)

配置类(使用弹簧)

@Configuration
public class RabbitConfiguration {

    @Bean
    public CachingConnectionFactory connectionFactory() {
        CachingConnectionFactory connectionFactory = new CachingConnectionFactory("www.example.com");
        connectionFactory.setUsername("xxxx");
        connectionFactory.setPassword("xxxx");
        return connectionFactory;
    }

    @Bean
    public MessageConverter jsonMessageConverter(){
        JsonMessageConverter jsonMessageConverter = new JsonMessageConverter();
        return jsonMessageConverter;
    }

    @Bean
    public SimpleMessageListenerContainer messageListenerContainer(){
        SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory());
        container.setAutoStartup(false);
        container.setQueues(indexQueue());
        container.setConcurrentConsumers(1);
        container.setAcknowledgeMode(AcknowledgeMode.AUTO);
        container.setMessageListener(new MessageListenerAdapter(pageListener(), jsonMessageConverter()));
        return container;
    }

    @Bean
    public Queue indexQueue(){
        return new Queue("pages.type.index");
    }

    @Bean
    public MessageListener pageListener(){
        return new PageQueueListener(); …
Run Code Online (Sandbox Code Playgroud)

java spring json amqp rabbitmq

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

注释资源以生成JSON,但在响应头中返回"text/plain"

我目前正在实施一个Web API

输出(如果有的话)将是JSON,因此我的所有类都使用预期的媒体类型进行注释.

@Produces(MediaType.APPLICATION_JSON)
public class CustomerResource {
    ...
}
Run Code Online (Sandbox Code Playgroud)

这样我的类就会自动转换为json.

但...

由于微软,他们的IE只支持CORS,如果请求/响应类型是text/plain http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and- workarounds.aspx

4. Only text/plain is supported for the request's Content-Type header
Run Code Online (Sandbox Code Playgroud)

所以我需要强制我的应用程序在标题中使用text/plain进行响应,但仍然将我的类投影到json输出.我知道我添加的CORS类是设置该标题,但不知何故,我的注释会再次覆盖它,即使我自己添加了另一个过滤器.

java spring json jersey cors

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

Jsoup将输出从单引号更改为HTML属性的双引号

我们使用Jsoup来解析,操作和扩展html模板.到目前为止,一切正常,直到与HTML属性结合使用的单引号

<span data-attr='JSON'></span>
Run Code Online (Sandbox Code Playgroud)

该HTML代码段已转换为

<span data-attr="JSON"></span>
Run Code Online (Sandbox Code Playgroud)

这将与仅使用双引号指定为有效的内部json数据冲突

{"param" : "value"} //valid
{'param' : 'value'} //invalid
Run Code Online (Sandbox Code Playgroud)

所以我们需要强制Jsoup 不要将那些单引号改为双引号,但是如何?目前,这是我们解析和生成html内容的代码.

pageTemplate = Jsoup.parse(new File(mainTemplateFilePath), "UTF-8");
pageTemplate.outputSettings().escapeMode(Entities.EscapeMode.xhtml);
pageTemplate.outputSettings().charset("UTF-8");

... adding some html 

pageTemplate.html(); // will output the double quoted attributes :(
Run Code Online (Sandbox Code Playgroud)

html javascript java jsoup

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

具有复杂或细粒度范围的OAuth 2.0

我目前正在为所有客户(网络和移动)开发OAuth2实施.到目前为止,没什么好看的,但是我们希望在范围上有更多的复杂性,这样我们就可以授予对某些对象的部分访问权限,直到单个属性的粒度.

示例:客户端获取资源的访问权限,假设具有其所有公共属性的用户对象.客户端具有完全读取权限,但只允许编辑某些属性,例如密码和用户名,但不能编辑位置和/或生日.

到目前为止,我的想法是,这种粒度是在授权服务器上定义的,只是由资源服务器解释.

基于RFC,scope是一个基于字符串的逗号分隔值,所以是一个简单的列表(http://tools.ietf.org/html/rfc6749#page-23)

scope参数的值表示为以空格
分隔的区分大小写的字符串列表.字符串由
授权服务器定义.如果值包含多个以空格分隔的字符串,则它们的顺序无关紧要,并且每个字符串都会
为请求的范围添加其他访问范围.

 scope       = scope-token *( SP scope-token )
 scope-token = 1*( %x21 / %x23-5B / %x5D-7E )
Run Code Online (Sandbox Code Playgroud)

因此,我提供json作为范围的第一个假设可能不起作用,所以我考虑引入可能变得复杂的命名空间,例如(范围:用户写入完整读取列表的属性或类似的东西).

有没有最好的做法,我在RFC中遗漏了什么或者我是否完全滥用OAuth?

authorization oauth-2.0

6
推荐指数
2
解决办法
2831
查看次数

使用 X.509 公共证书加密和解密

我想使用 X.509 证书和继承的公钥来加密我的帖子有效负载。到目前为止我有这个java代码来执行加密

private String encrypt(String str) throws Exception {
    ClassPathResource classPathResource = new ClassPathResource("testcert1.crt");
    CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
    X509Certificate certificate = (X509Certificate)certificateFactory.generateCertificate(classPathResource.getInputStream());
    PublicKey pk = certificate.getPublicKey();
    Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1PADDING");
    cipher.init(Cipher.ENCRYPT_MODE, pk);
    return Base64.encodeBase64String(cipher.doFinal(str.getBytes()));
}
Run Code Online (Sandbox Code Playgroud)

它返回 base64 编码的字符串。从端点我总是得到结果,证书无效。

所以我想使用该openssl命令在控制台上验证我的加密字符串,但未能这样做。

我可以通过以下方式读出证书:openssl x509 -in testcert1.crt -text -noout

Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: 0 (0x0)
        Signature Algorithm: md5WithRSAEncryption
        Issuer: C=xxx, ST=xxx, L=xxx, O=xxx, OU=xxx, CN=xxx
        Validity
            Not Before: Jul 24 11:40:39 2013 GMT
            Not After : Jul …
Run Code Online (Sandbox Code Playgroud)

java encryption shell ssl openssl

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

在spring应用程序上下文中有条件地导入资源

只有满足某个条件,我才能在弹簧环境中导入东西吗?

<!-- import ONLY IF current environment is NOT testing -->
<import resource="classpath:context/caching-context.xml" />
Run Code Online (Sandbox Code Playgroud)

目前我通过在我的测试用例中导入完全不同的上下文来做到这一点

@ContextConfiguration(locations = { "classpath*:ApplicationContextTesting.xml" })
Run Code Online (Sandbox Code Playgroud)

但也许有一个更优雅的解决方案,不能为生产和测试维护两个独立的应用程序上下文.

java spring

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

Ehcache不允许持久性元素

我使用的是Ehcache 2.7版

的pom.xml

<dependency>
    <groupId>net.sf.ehcache</groupId>
    <artifactId>ehcache</artifactId>
    <version>2.7.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

上下文cache.xml

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="
    http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
    http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/cache 
    http://www.springframework.org/schema/cache/spring-cache.xsd">

<!-- generic cache manager -->
<cache:annotation-driven />

<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"
 p:cacheManager-ref="ehcache"/>

<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
    p:configLocation="classpath:ehcache.xml" p:shared="true" />
Run Code Online (Sandbox Code Playgroud)

ehcache.xml中

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" updateCheck="true"
monitoring="autodetect" dynamicConfig="true">   

    <defaultCache eternal="true" maxElementsInMemory="100" overflowToDisk="false" />
    <cache name="AC" maxElementsInMemory="50000" eternal="true" overflowToDisk="false">
        <persistence strategy="localRestartable" synchronousWrites="false" />
    </cache>

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

我得到以下例外

org.xml.sax.SAXException: null:9: Element <cache> does not allow nested <persistence> elements.
Run Code Online (Sandbox Code Playgroud)

即使允许进入 http://ehcache.org/ehcache.xsd

<xs:element minOccurs="0" maxOccurs="1" ref="persistence"/>
Run Code Online (Sandbox Code Playgroud)

我没有得到导致该问题的原因以及为什么SAX抱怨 …

spring ehcache

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