小编Müs*_*sli的帖子

将日期字符串转换为其他格式的日期字符串

我需要将日期格式的字符串转换为日期格式yyyyMMdd的日期字符串MM/dd/yyyy。哪个是最好的?

我正在这样做:

DateTime.ParseExact(dateString, "yyyyMMdd", CultureInfo.InvariantCulture).ToString("MM/dd/yyyy")
Run Code Online (Sandbox Code Playgroud)

但是我不确定,我认为必须有更好的方法。你怎么看?

c# date-conversion date-parsing

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

十进制格式c#

我有以下问题:我需要将十进制数转换为字符串.示例:11.350(十一万三百五十)

lbl_valorBuyin.Text =   
   (Valid.GetDecimal(TORNEO.RBUYIN) + 
     Valid.GetDecimal(TORNEO.VALORBOUNTY)).ToString("###,###");
Run Code Online (Sandbox Code Playgroud)

输出是11,350,我希望它是11.350.在将十进制值转换为字符串时,我不清楚使用格式.

我尝试过不同的格式,但不是大小写.我无法解决这个问题.

你能帮助我吗?

提前致谢.

.net c#

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

Spring MVC 3 + JSON

我正在尝试使用带有JSON的Spring MVC.当从控制器返回一个对象时,它工作得很好,但是当我尝试将一个自定义对象作为参数传递给AJAX时,我收到HTTP 415错误.

我的spring-servlet.xml:

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

    <tx:annotation-driven /> 
   <context:annotation-config/>
    <context:component-scan
        base-package="com.sommer.controller" />
        <tx:annotation-driven transaction-manager="transactionManager"/>

    <context:component-scan base-package="com.sommer.service" />

    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <property name="viewClass"
            value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/WEB-INF/view/" />
        <property name="suffix" value=".jsp" />
    </bean>

    <bean id="messageSource"
    class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
        <property name="basename" value="classpath:messages" />
        <property name="defaultEncoding" value="UTF-8"/>
    </bean>


 <!-- ========= [ADDED FOR JSON SUPPORT] ========= -->
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
       <property name="messageConverters">
           <list>
                <ref bean="jsonConverter" />
           </list>
       </property>
    </bean>

    <bean id="jsonConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
       <property name="supportedMediaTypes" value="application/json" /> …
Run Code Online (Sandbox Code Playgroud)

json spring-mvc

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

Rails 3内联错误

我是rails 3中的新手.我正在使用bootstrap,我想在无效字段旁边显示验证错误.

这是代码

<div class="control-group <%= @pet.errors.has_key?(:nick) ? "error": "" %>">
        <%= f.label :nick, :class => 'control-label' %>
        <div class="controls">
            <%= f.text_field :nick, :class => 'text_field' %>
            <% unless !@pet.errors.has_key?(:nick)%>
            <span class="help-inline"><%= @pet.errors[:nick]%></span>
            <%end%>
        </div>
    </div>
Run Code Online (Sandbox Code Playgroud)

我的问题是<%= @pet.errors[:nick]%>退货

["no puede estar en blanco"]
Run Code Online (Sandbox Code Playgroud)

而且必须是公正的

no puede estar en blanco
Run Code Online (Sandbox Code Playgroud)

在这里你有一个图像

http://img848.imageshack.us/img848/8263/inlineerror.jpg

有什么办法可以在没有方括号和引号的情况下得到错误信息吗?

提前致谢

ruby-on-rails-3

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