使用一些批处理文件,我想在Java Keystore中添加不受信任的自签名证书.
命令是
%JAVA_HOME%/bin/keytool -import -v -trustcacerts -alias server-alias
-file server.cer -keystore cacerts.jks -keypass changeit -storepass changeit
Run Code Online (Sandbox Code Playgroud)
运行上述命令后,屏幕将使用Y/N进行证书信任.
Trust this certificate? [no]:
Run Code Online (Sandbox Code Playgroud)
但我不想在这里提供Y/N.
有没有办法使用单个命令或一些额外的导入开关完成导入?请帮忙.
问候,
阿伦
我有一些混乱的类型 simpletype
,simplecontent
,complextype
和complexcontent
.
我几乎是xsd的新手.有人可以帮助清除给出具体例子的困惑.
我发现了JSON和XML之间的区别.因为,两者都用于系统之间的数据交换,但JSON和XML之间存在很大差异,JSON比XML更轻量级.但我无法找到为什么JSON重量轻的实际原因.是什么让JSON重量轻?
我发现一个答案是在JSON中没有很多额外的xml标记.它实际意味着什么.是否还有一些原因可以解释为什么JSON是轻量级的?
我们怎么能制作一个jar文件的安装程序,它可以在多平台上运行.有没有简单的方法,因为我不太了解Java.
Balwant
我正在使用Spring 3.1为iPhone和Android应用程序创建Restful网站和Web服务.在我的应用程序中,我使用Spring Message Convertors(org.springframework.http.converter.json.MappingJacksonHttpMessageConverter
)将JSON转换为Java对象,反之亦然.
我的目标是JSP页面,Iphone/Andois app应该只使用单个控制器方法(相同的URL).
我使用Spring表单标签进行从JSP到控制器的对象绑定,@ModelAttribute
如下所示.
@RequestMapping(value = "reset-password", method = RequestMethod.POST)
public ModelAndView resetPassword(@ModelAttributeForgot forgotPassword,
HttpServletRequest request) {
System.out.println("data recived=="+forgotPassword.getNewPassword());
}
Run Code Online (Sandbox Code Playgroud)
但是,如果数据是从iPhone/Android应用程序发布的,那么同样的情况就不适用了,结果是:
recived = = null;
所以为了克服这个问题,我@RequestBody
在地方使用了注释@ModelAttribute
.
所以我的控制器如下所示:
@RequestMapping(value = "reset-password", method = RequestMethod.POST)
public ModelAndView resetPassword(@RequestBody Forgot forgotPassword,
HttpServletRequest request) {
System.out.println("data recived=="+forgotPassword.getNewPassword());
}
Run Code Online (Sandbox Code Playgroud)
它的工作原理,我得到的结果是:
收到的数据== somedata;
但是@RequestBody然后在JSP页面上不能使用spring表单,并且数据不会转换为对象而且我得到了null
值.
@RequestBody
注释以JSP形式的弹簧形式标签以JSON的形式发布数据吗?编辑:
在写String
到位Bean类的,我能够获得纯文本格式的内容,如下图所示:
@RequestMapping(value = "reset-password", method = RequestMethod.POST)
public …
Run Code Online (Sandbox Code Playgroud) 我使用Jasypt-1.9.0与弹簧3.1和Hibernate的4.0.1.我的应用程序中要求连接到数据库,其密码(root)以加密形式存储在应用程序的属性文件中.
我在网上查找了以下链接:
我已根据我的要求完成了以下步骤和配置:
<bean id ="propertyConfigurer"class ="org.jasypt.spring31.properties.EncryptablePropertyPlaceholderConfigurer">
Run Code Online (Sandbox Code Playgroud)< constructor-arg ref="configurationEncryptor" /> < property name="locations"> < list> < value>classpath:database.properties< /value> < /list> < /property> < /bean> < bean id="configurationEncryptor" class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor"> < property name="config" ref="environmentVariablesConfiguration" /> < /bean> < bean id="environmentVariablesConfiguration" class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig"> < property name="algorithm" value="PBEWithMD5AndDES" /> < property name="passwordEnvName" value="APP_ENCRYPTION_PASSWORD" /> </bean>
- 添加了一个新的Environment Varibale作为APP_ENCRYPTION_PASSWORD,其值为root
我必须发送一封电子邮件,其中包含html中的所有内容,可以在电子邮件中显示为HTML.我能够发送带有JavaMailSenderImpl
Spring Framework SimpleMailMessage
的电子邮件,但我发送的电子邮件以简单的html文本显示,如下所示
<html><body><h1>Hello</h1></body></html>
Run Code Online (Sandbox Code Playgroud)
而不是HTML页面的形式.
请告诉我如何将其作为HTML发送以及如何以HTML格式显示.
我在我的Web应用程序中使用Spring 3.1 + Hibernate 4.x. 在我的DAO中,我正在保存用户类型对象,如下所示
sessionFactory.getCurrentSession().save(user);
Run Code Online (Sandbox Code Playgroud)
但是获得以下异常:
org.hibernate.HibernateException: save is not valid without active transaction
Run Code Online (Sandbox Code Playgroud)
我用Google搜索并在SO上找到了类似的问题,并提供以下解决方案:
Session session=getSessionFactory().getCurrentSession();
Transaction trans=session.beginTransaction();
session.save(entity);
trans.commit();
Run Code Online (Sandbox Code Playgroud)
这解决了这个问题.但是在那个解决方案中,开始并手动提交事务有很多混乱.
sessionFactory.getCurrentSession().save(user);
如果没有手动开始/提交交易,我不能直接使用 吗?
我也尝试使用@Transactional
我的服务/ dao方法,但问题仍然存在.
编辑:这是我的Spring配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
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.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">
<!-- enable the configuration of transactional behavior based on annotations -->
<tx:annotation-driven transaction-manager="txManager"/>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="${db.driverClassName}" p:url="${db.url}"
p:username="${db.username}" p:password="${db.password}" />
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" /> …
Run Code Online (Sandbox Code Playgroud) 我的Web应用程序使用Apache CXF和JAVA8,并且如果用户将xs:datetime
输入(秒00)发送为,则响应以下错误
<urn1:dateTimeVal>2016-04-29T20:00:00</urn1:dateTimeVal>
Run Code Online (Sandbox Code Playgroud)
错误:
org.apache.cxf.interceptor.Fault:编组错误:cvc-datatype-valid.1.2.1:'2016-04-29T20:00'不是'dateTime'的有效值。
我进行了调试和分析,如果用户发送dateTimeVal
as,2016-04-29T20:00:00
则传递输入的CXF验证并将XML值取消编组为java.time.LocalDateTime
as 2016-05-05T20:00
,并且在返回响应时,由于秒损失part(00)而发生了编组错误。
任何帮助/提示表示赞赏。
PS:您可以尝试以下代码段:
java.time.LocalDateTime dt= java.time.LocalDateTime.of(2016, Month.MAY, 5, 20, 00, 00);
System.out.println(dt);
Run Code Online (Sandbox Code Playgroud)
注意:上面的代码示例仅用于理解打印日期时间值。但是,Web应用程序中期望的实际返回类型是java.time.LocalDateTime
预期输出:2016-05-05T20:00:00
实际产量 :2016-05-05T20:00
编辑:该字段的绑定(JAXB)内容是:
@XmlElement(required = true, type = String.class)
@XmlJavaTypeAdapter(LocalDateTimeAdapter.class)
@XmlSchemaType(name = "dateTime")
@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-05-03T05:28:57+05:30", comments = "JAXB RI v2.2.11")
@NotNull
protected LocalDateTime dateTimeVal;
Run Code Online (Sandbox Code Playgroud)
AND LocalDateTimeAdapter
文件为
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.time.temporal.TemporalAccessor;
import …
Run Code Online (Sandbox Code Playgroud) 我正在使用Spring 3.0创建一个RESTful网站.我正在使用ContentNegotiatingViewResolver
HTTP消息转换器(如MappingJacksonHttpMessageConverter
JSON,MarshallingHttpMessageConverter
XML等).我能够成功获取XML内容,如果我在url的最后一个使用.xml后缀,并且在URL中使用带有.json后缀的JSON时也是如此.
从控制器获取XML/JSON内容对我来说不会产生任何问题.但是,如何在同一个Controller方法中使用请求体来发布XML/JSON?
例如
@RequestMapping(method=RequestMethod.POST, value="/addEmployee")
public ModelAndView addEmployee(@RequestBody Employee e) {
employeeDao.add(e);
return new ModelAndView(XML_VIEW_NAME, "object", e);
}
Run Code Online (Sandbox Code Playgroud)