我已经开始使用谷歌应用程序引擎和Spring 4开发一个Web应用程序.但现在我已经明白Spring 4并不完全支持Google应用程序引擎.现在我需要最新版本的Spring框架,完全支持谷歌应用程序引擎.有人可以帮帮我吗?
我有这个基于xml的配置.但在我的项目中,我想使用基于java注释的配置.怎么做转换?
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="mail.csonth.gov.uk"/>
</bean>
<bean id="registrationService" class="com.foo.SimpleRegistrationService">
<property name="mailSender" ref="mailSender"/>
<property name="velocityEngine" ref="velocityEngine"/>
</bean>
<bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
<property name="velocityProperties">
<value>
resource.loader=class
class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
</value>
</property>
</bean>
</beans>
Run Code Online (Sandbox Code Playgroud) 我的 html 页面中有一个输入按钮。我想用 thymeleaf 将按钮链接到另一个 html 页面。这是我的代码。
<form id="hotDealForm" th:action="@{/hot-deal-step-1}">
<div class="col-xs-12 col-sm-6 col-md-6">
This Hot deal
<br/>
<input type="button" value="Continue to schedule" class="btn btn-red"/>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
我的控制器工作正常。(我正在使用 spring mvc)。但我不知道问题出在哪里。我可以使用 html 完成相同的任务。但是当我使用百里香时它不起作用。那是当我点击按钮时什么也没有发生。
更新2: 我发现输入的标题由于某种原因被显示为错误消息,我使用了ignoreTitle:true来确保他的标题没有被显示为错误消息。
但是,现在我的新问题是,一旦输入有效的电子邮件地址,该错误消息仍不会消失。
如何解决我的验证错误消息,以便在输入字段有效时将其隐藏?
我是jQuery Validation的新手,我似乎无法弄清楚这个问题。在此问题上的任何帮助将不胜感激。谢谢!
更新内容2:http: //jsfiddle.net/psbq8vkj/9/
JQUERY:
$(".guestlist-form").validate({
ignoreTitle: true,
errorClass: "error-class",
validClass: "valid-class",
rules: {
emailaddress: {
required: true,
email: "Please enter your correct email address."
}
},
errorPlacement: function(error, element) {
$(".myerror").html(''); // clears previous error messages
error.appendTo( ".myerror");
},
messages: {
emailaddress: {
required: "Please enter your full email address."
}
}
});
Run Code Online (Sandbox Code Playgroud)
HTML:
<div id="updates" class="container-fluid">
<center>
<div class="title"><br />
<span class="signuptitle">Sign up to our daily newsletter.</span><br/>
</div>
<div …Run Code Online (Sandbox Code Playgroud) 我有一个名为“通知”的列表,我使用 Thymeleaf“每个方法”来一一访问其元素。我可以成功地做到这一点,如下所示。
<li th:each="n : *{notifications}">
<h4 type="text" th:text="*{n.message}"></h4>
</li>
Run Code Online (Sandbox Code Playgroud)
注意:“message”是我需要从列表中检索的属性。
如何以相反的顺序访问元素?例如,如果这是我当前的输出,
Cat
Dog
Rat
Run Code Online (Sandbox Code Playgroud)
我怎样才能得到这样的输出?
Rat
Dog
Cat
Run Code Online (Sandbox Code Playgroud) 我的UI有一些从Bootstrap创建的下拉列表,我用它来包含一些表单元素.我通过我在这里找到的解决方案阻止了下拉关闭,这几乎是完美的: 避免下拉菜单关闭内部点击
剩下的问题是我使用Select2 mutliple选择并删除选项的特定实例.删除行为似乎遵循不同的事件链,因为它关闭了下拉列表.我的假设是事件传播到父元素,但我似乎无法确定哪个.
这是一个JSFiddle来说明这个问题.选择一个选项,然后将其删除以查看会发生什么.下面是包含jsfiddle时所需的代码.当然,它从我的实际代码中减少,但至少代表了这个问题.
$('body').on('click', '.dropdown .cycle-element', function(e) {
$(this).parent().toggleClass('open');
});
$('body').on('click', function(e) {
if (!$('.dropdown').is(e.target) && $('.dropdown').has(e.target).length === 0 && $('.open').has(e.target).length === 0) {
$('.dropdown').removeClass('open');
}
});
$('.dependency-select').select2();
Run Code Online (Sandbox Code Playgroud) 我已经根据其他解决方案进行了几处更改,但没有一个能够解决我的问题。尝试运行应用程序时出现以下错误。
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.NoSuchProviderException: No provider for SMTP. Failed messages: javax.mail.NoSuchProviderException: No provider for SMTP; message exceptions (1) are: Failed message 1: javax.mail.NoSuchProviderException: No provider for SMTP
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:317)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:150)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:124)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177) …Run Code Online (Sandbox Code Playgroud) 我需要更新mysql表中的字符串值.为此,我写了一个方法如下.
@Repository
public interface NotificationRepository extends JpaRepository<Notification, Long> {
@Modifying
@Query("update Notification msg set msg.message = ?1 where msg.applicationUser.id = ?2")
String createNewNotification(String message, Long id);
}
Run Code Online (Sandbox Code Playgroud)
我得到以下例外.
java.lang.IllegalArgumentException: Modifying queries can only use void or int/Integer as return type!
Run Code Online (Sandbox Code Playgroud)
我无法更新表格中的字符串值.只有void或int是可能的吗?这是什么意思?我该如何处理此异常?请帮忙.
我想用Java Map填充以下文本的占位符.
String text = "Media file %s of size %s has been uploaded";
Run Code Online (Sandbox Code Playgroud)
这就是我在地图中输入值的方式.
Map<String, String> properties = new HashMap<>();
properties.put(MediaFile.fileName, "Sample 001");
properties.put(MediaFile.fileSize, "2Mb");
Run Code Online (Sandbox Code Playgroud)
我希望输出文本是这样的.
Media file Sample 001 of size 2Mb has been uploaded
Run Code Online (Sandbox Code Playgroud)
但我把它作为输出.
Media file 2Mb of size 2Mb has been uploaded
Run Code Online (Sandbox Code Playgroud)
我创建了一个类来保存变量fileName和fileSize.
public class MediaFile {
public static String fileName;
public static String fileSize;
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我像下面一样使用它,它工作正常.但我想分开fileName和fileSize.但我不确定我是否正确实现了MediaFile类.谁能告诉我我的代码有什么问题?
properties.put("fileName", "Sample 001");
properties.put("fileSize", "2Mb");
Run Code Online (Sandbox Code Playgroud)