我在使用@Valid参数处理器上的处理程序方法时遇到问题@Controller.我的代码看起来像这样:
@RequestMapping(value=BIBBLE_BOBBLE_URI_PATTERN + "/widgets", method=RequestMethod.POST)
@ResponseBody
@ResponseStatus(HttpStatus.CREATED)
public Widget saveNewWidget(
@PathVariable final String username,
@PathVariable final String bibbleBobbleName,
@Valid @RequestBody final Widget widget,
final BindingResult results,
final HttpServletRequest request,
final HttpServletResponse response)
Run Code Online (Sandbox Code Playgroud)
其中Widget一个域对象的类在哪里.我正在使用@RequestBody注释来指示请求的有效负载映射到widget(在我的测试中,请求是JSON,尽管Jackson在我的类路径上,所以我也可以使用XML).
如您所见,该BindingResult参数紧跟在Widget参数之后,但是我收到以下错误:
java.lang.IllegalStateException: Errors/BindingResult argument declared without preceding model attribute. Check your handler method signature!
Run Code Online (Sandbox Code Playgroud)
如何将@Valid注释应用于@RequestBody参数然后获得结果?
PS我正在annotation-driven用来处理控制器的连接,进行内容协商等.
我想知道FMS,wowza和Flash Media Server之间的主要技术差异是什么.如果有人有比较表或链接,请帮助.
我需要从表单类型中翻译错误消息.这是我的表单类型代码:
class ReferFriendType extends AbstractType {
public function buildForm(FormBuilder $builder, array $options)
{
$defaultSubject = "This is a default referral subject.";
$defaultMessage = "This is a default referral message.";
$builder->add('email1', 'email',array(
'required' => true,
'label' => 'Email 1* :',
'attr' => array('class' => 'large_text'),
));
$builder->add('email2', 'email',array(
'label' => 'Email 2 :',
'required' => false,
'attr' => array('class' => 'large_text'),
));
$builder->add('email3', 'email',array(
'label' => 'Email 3 :',
'required' => false,
'attr' => array('class' => 'large_text'),
));
$builder->add('email4', 'email',array(
'label' …Run Code Online (Sandbox Code Playgroud) 在我的表单中,我有一些复选框,但默认情况下,我有:
这是SYmfony2生成的html代码:
<div>
<input ...>
<label ...></label>
<input ...>
<label ...></label>
</div>
Run Code Online (Sandbox Code Playgroud)
什么我想是有:
第一无线电窗口小部件的第一个标签
的第二无线电窗口小部件的第二个标签
HTML代码将是:
<label .....><input ....></label>
Run Code Online (Sandbox Code Playgroud)
我想我必须覆盖choice_widget,但不知道如何将输入和标签放在同一行
这是我可能需要覆盖的choice_widget:
{% block choice_widget %}
{% spaceless %}
{% if expanded %}
<div {{ block('widget_container_attributes') }}>
{% for child in form %}
{{ form_widget(child) }} {{ form_label(child) }}
{% endfor %}
</div>
{% else %}
<select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}>
{% if empty_value is not none %} …Run Code Online (Sandbox Code Playgroud) 我在我的表单中有一个名为*sub_choice*的选择字段类型,其选择将通过AJAX动态加载,具体取决于父选择字段的选定值,名为*parent_choice*.加载选项非常有效,但在提交时验证sub_choice的值时遇到问题.它给出了"此值无效"验证错误,因为提交的值在构建时不在sub_choice字段的选项中.那么有没有办法可以正确验证sub_choice字段的提交值?下面是构建表单的代码.我正在使用Symfony 2.1.
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('parent_choice', 'entity', array(
'label' => 'Parent Choice',
'class' => 'Acme\TestBundle\Entity\ParentChoice'
));
$builder->add('sub_choice', 'choice', array(
'label' => 'Sub Choice',
'choices' => array(),
'virtual' => true
));
}
Run Code Online (Sandbox Code Playgroud) 查看我的prod日志后,我提到了一些错误:
[2012-08-31 15:56:43] request.CRITICAL: Doctrine\DBAL\DBALException:
An exception occurred while executing 'SELECT t0.username ....... FROM fos_user t0 WHERE t0.username = ?'
with params {"1":"Nrv\u29e7Kasi"}:
SQLSTATE[HY000]: General error: 1267 Illegal mix of collations (latin1_swedish_ci,IMPLICIT)
and (utf8_general_ci,COERCIBLE) for operation '='
Run Code Online (Sandbox Code Playgroud)
Alghout我在学说cfg下有UTF-8默认值:
doctrine:
dbal:
charset: UTF8
Run Code Online (Sandbox Code Playgroud)
好像我的所有MySQL表都在latin1_swedish_ci,所以我的问题是:
我是否可以手动更改utf8_general_ci所有表格的校对而无需任何复杂/预防措施?
所以我正在阅读symfony2 http://symfony.com/doc/current/book/internals.html的内部文档,我不明白这一节http://symfony.com/doc/current/book/internals.html#events.
所以,我想知道MASTER/SUB REQUEST之间的区别?
比方说,我有一个字段,user_name在表格中应该是唯一的.
使用Spring/Hibernate验证验证它的最佳方法是什么?
在详尽搜索了Web和Stackoverflow之后,我仍然在试图弄清楚如何集成Jersey和Jetty提供的RESTlet样式接口.
我的Jetty服务器已启动并运行,因此Jersey似乎也很容易使用,有没有人知道如何将两者结合在一起?任何具体的链接都会有所帮助 - 我对servlet编程也有点新意.
我正在构建我的第一个Symfony2项目,我可能会对web/bundles文件夹的目的感到困惑.根据Symfony2文档,他们说这是静态数据像js库,css和图像的地方.这一切都有意义,但是当你仍在构建基础布局/web/bundles时,忽略列表上是不是有点烦人?事实上为什么甚至把它放在忽略列表上?引导程序,参数,缓存等都是有意义的,因为您不希望跨越生成设置的开发设置.
这就是symfony指示你添加到gitignore的内容:
/web/bundles/
/app/bootstrap*
/app/cache/*
/app/logs/*
/vendor/
/app/config/parameters.yml
Run Code Online (Sandbox Code Playgroud) symfony ×6
java ×2
spring ×2
symfony-2.1 ×2
validation ×2
collation ×1
comparison ×1
data-binding ×1
forms ×1
git ×1
gitignore ×1
hibernate ×1
jax-rs ×1
jersey ×1
jetty ×1
mysql ×1
php ×1
red5 ×1
servlets ×1
spring-mvc ×1
twig ×1