我最近从Eclipse迁移到了IntelliJ.这是一个挑战,因为我是一个键盘快捷迷,但这不是我在这里的意思.
我想念包/项目视图中显示的git分支名称.
有没有人知道配置IntelliJ以显示项目所在的git分支的方法,所以我不必继续切换回终端并检查.
谢谢.
如果我在Spring控制器中有一个RequestMapping,那么......
@RequestMapping(method = RequestMethod.GET, value = "{product}")
public ModelAndView getPage(@PathVariable Product product)
Run Code Online (Sandbox Code Playgroud)
而产品是一个枚举.例如.Product.Home
当我请求页面时,mysite.com/home
我明白了
Unable to convert value "home" from type 'java.lang.String' to type 'domain.model.product.Product'; nested exception is java.lang.IllegalArgumentException: No enum const class domain.model.product.Product.home
Run Code Online (Sandbox Code Playgroud)
有没有办法让枚举类型转换器了解小写主页实际上是Home?
我想保持url不区分大小写和我的Java枚举标准大写字母.
谢谢
解
public class ProductEnumConverter extends PropertyEditorSupport
{
@Override public void setAsText(final String text) throws IllegalArgumentException
{
setValue(Product.valueOf(WordUtils.capitalizeFully(text.trim())));
}
}
Run Code Online (Sandbox Code Playgroud)
注册它
<bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="customEditors">
<map>
<entry key="domain.model.product.Product" value="domain.infrastructure.ProductEnumConverter"/>
</map>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
添加到需要特殊转换的控制器
@InitBinder
public void initBinder(WebDataBinder binder)
{
binder.registerCustomEditor(Product.class, new ProductEnumConverter());
}
Run Code Online (Sandbox Code Playgroud) 在经典的web.xml类型配置中,您可以配置上下文参数,如此
web.xml中
...
<context-param>
<param-name>p-name</param-name>
<param-value>-value</param-value>
</context-param>
...
Run Code Online (Sandbox Code Playgroud)
如何在spring-boot中实现.我有一个需要参数的过滤器.
我正在使用@EnableAutoConfiguration并包含<artifactId>spring-boot-starter-jetty</artifactId>在我的pom中.
为什么spring没有绑定嵌套对象上的值?
尽管在视图中使用bean表示法在表单中进行设置,但RegistrationBean上的SecurityQuestion对象分别设置为问题和答案为null,null.
豆子:
public class SecurityQuestion {
SecurityQuestionType type;
String answer;
}
public class RegistrationBean {
@Valid
SecurityQuestion securityQuestion;
String name;
public SecurityQuestionType[] getSecurityQuestionOptions() {
return SecurityQuestionType.values();
}
}
Run Code Online (Sandbox Code Playgroud)
视图:
<form:form modelAttribute="registrationBean" method="POST">
<form:select id="securityQuestion" path="securityQuestion.question">
<c:forEach var="securityQuestionOption" items="${securityQuestionOptions}">
<form:option value="${securityQuestionOption}">${securityQuestionOption</form:option>
</c:forEach>
</form:select>
<form:input id="securityAnswer" path="securityQuestion.answer" />
<form:input id="name" path="name" />
</form:form>
Run Code Online (Sandbox Code Playgroud)
控制器:
@RequestMapping(value = URL_PATTERN, method = RequestMethod.POST)
public ModelAndView submit(@Valid final RegistrationBean registrationBean) {
// registrationBean.getSecurityQuestion().getQuestion() == null
// registrationBean.getSecurityQuestion().getAnswer() == null
}
Run Code Online (Sandbox Code Playgroud)
解
所有bean都必须拥有所有字段的getter/setter.Spring使用默认构造函数,然后使用setter从视图中改变对象.
我想为id - > entity使用自定义WebArgumentResolver.如果我使用请求参数,则足够简单:使用参数键确定实体类型并相应地查找.
但我希望它像@PathVariable注释.
例如.
http://mysite.xzy/something/enquiryId/itemId会触发此方法
@RequestMapping(value = "/something/{enquiry}/{item}")
public String method(@Coerce Enquiry enquiry, @Coerce Item item)
Run Code Online (Sandbox Code Playgroud)
@Coerce注释会告诉WebArgumentResolver根据它的类型使用特定服务.
问题在于哪个uri部分属于实体.
有人可以解释PathVariable注释如何做到这一点.是否可以使用我的自定义注释来模拟它.
谢谢.
@Before(value = "@annotation(OwnershipCheck) && args(enquiry)")
public void checkOwnership(Enquiry enquiry) throws Throwable
{
}
Run Code Online (Sandbox Code Playgroud)
上面的表达式将匹配任何带有 OwnershipCheck 注释的方法,并将查询作为参数。
如何使用 OwnershipCheck 注释为任何方法扩展此表达式,并在有或没有其他参数的任何位置进行查询。
也就是说,需要匹配
@OwnershipCheck
public void one(Enquiry enquiry)
@OwnershipCheck
public void two(Object obj, Enquiry enquiry)
@OwnershipCheck
public void three(Enquiry enquiry, Object ob)
@OwnershipCheck
public void four(Object obj, Enquiry enquiry, Object other)
Run Code Online (Sandbox Code Playgroud) 我正在使用RabbitMQ并尝试重构我当前的本机java实现以使用Spring AMQP抽象.
使用Spring库声明交换,队列及其绑定是通过AMQPAdmin接口,但我不确定何时应该进行这种配置.
我有一个使用Rabbit生成消息的Web应用程序.另一个消费这些消息的应用程序.震惊:)
但是当显示交换/队列的声明时?
我是否将AMQPAdmin与Web应用程序一起部署,并在生产者和消费者的构造函数中进行交换/队列管理?
这些事情的宣言是一次性的,破产不需要再次了解它们,因此任何代码都将成为后续执行的NOOP.
我是否为管理代理创建了单独的应用程序?
这里目前的想法或最佳做法是什么?
下面的方法失败,出现"PatternSyntaxException:Unclosed count closure near index ..."
@RequestMapping(value ="/{id:[0-9|a-z]{15}}")
public View view(@PathVariable final String id) {
...
}
Run Code Online (Sandbox Code Playgroud)
看起来模式匹配器正在修剪过多的字符串而丢失了最后一个}.
有没有人知道这个bug的工作?我不得不将限定符放到"/ {id:[0-9 | az] +}" - 这很坦率!
Git是分布式源代码控制系统,对.如何连接两个没有集中存储库的开发人员.
我们的团队使用Github,如果两个开发人员想要在同一个分支上工作,那么看起来分支需要在他们都可以访问它之前被推送到远程...或者它是什么?
开发人员是否可以从另一个开发人员本地存储
java ×5
spring-mvc ×5
spring ×4
git ×2
aspectj ×1
github ×1
jetty ×1
jsp ×1
messaging ×1
regex ×1
spring-3 ×1
spring-boot ×1
spring-form ×1