我有一些string
,我想用使用C#的SHA-256哈希函数来哈希它.我想要这样的东西:
string hashString = sha256_hash("samplestring");
Run Code Online (Sandbox Code Playgroud)
框架中是否有内置功能可以执行此操作?
我正在尝试备份postgresql的数据库,我想使用pg_dump
命令.
我试过了 :
psql -U postgres
postgres-# pg_dump test > backup.sql
Run Code Online (Sandbox Code Playgroud)
但我不知道输出文件的位置.
任何帮助将不胜感激
我正在尝试使用简单的表单添加名称和颜色的活动.
所以我想制作一个带有一些颜色数组的列表,现在它正在工作我有颜色的名称.
我可以在select标签中添加任何属性:
$form = $this->createFormBuilder($myclass)
->add('Colors','choice',array('label'=>'select some colors',
'multiple'=>true,
'choices'=>array(1=>'red', 2=>'blue', 3=>'green'),
'attr'=>array('style'=>'width:300px', 'customattr'=>'customdata')
));
Run Code Online (Sandbox Code Playgroud)
输出将是这样的:
<select name="select" style="width: 300px;" multiple="multiple" customattr="customdata">
<option value="1">red</option>
<option value="2">blue</option>
<option value="3">green</option>
</select>
Run Code Online (Sandbox Code Playgroud)
但是,如何添加selected="selected"
我想要的任何属性以及我的选择选项?像这样:
<select name="select" style="width: 300px;" multiple="multiple" customattr="customdata">
<option style="background-color: #F00;" value="1" selected="selected">red</option>
<option style="background-color: #00F;" value="2" selected="selected">blue</option>
<option style="background-color: #0F0;" value="3">green</option>
</select>
Run Code Online (Sandbox Code Playgroud)
我的问题是:如何通过symfony FormBuilder option
为select
标签添加自定义attr (而不是标签).
注意:我不想使用JavaScript.我想使用symfony2 FormBuilder来自定义我的选择选项.
你知道Javascript是一种基于原型的编程语言.
我已经阅读了一些关于Javascript及其原型继承概念的书籍,但是:
"如果你无法解释给一个六岁,你真的不明白自己了."嗯,我试图解释的JavaScript原型的概念,一个22岁的朋友,完全没有!
您如何向一个对该主题感兴趣的6岁的人解释?
我已经看到Stack Overflow中给出的一些示例,但它没有帮助.
javascript prototype prototypejs prototypal-inheritance prototype-programming
我正在使用Spring + Hibernate + Spring-MVC.
我想定义一个自定义约束,结合其他两个预定义的验证注释:@NotNull @Size
像这样:
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
@NotNull
@Size(min=4)
public @interface JPasswordConstraint {
} // this is not correct. It's just a suggestion.
Run Code Online (Sandbox Code Playgroud)
我想在我的表单模型中使用此注释.
public class ChangePasswordForm {
@NotNull
private String currentPass;
@JPasswordConstraint
private String newPass;
@JPasswordConstraint
private String newPassConfirm;
}
Run Code Online (Sandbox Code Playgroud)
@RequestMapping(value = "/pass", method = RequestMethod.POST)
public String pass2(Model model, @Valid @ModelAttribute("changePasswordForm") ChangePasswordForm form, BindingResult result) {
model.addAttribute("changePasswordForm", form);
try {
userService.changePassword(form);
} catch (Exception ex) {
result.rejectValue(null, "error.objec", ex.getMessage()); …
Run Code Online (Sandbox Code Playgroud) 我在Spring项目中一直使用Hibernate Validator.我即将JUser
自动验证我的对象.即,我希望Spring验证对象并在BindigResult中设置错误.但它不起作用.
<properties>
<spring.version>4.3.5.RELEASE</spring.version>
<spring.security.version>4.0.2.RELEASE</spring.security.version>
<hibernate.version>4.3.11.Final</hibernate.version>
<validation-api.version>1.1.0.Final</validation-api.version>
<hibernate-validator.version>5.4.0.Final</hibernate-validator.version>
</properties>
....
Run Code Online (Sandbox Code Playgroud)
...
<tx:annotation-driven transaction-manager="hibernateTransactionManager"/>
<context:annotation-config />
<context:component-scan base-package="my.project.controller" />
<mvc:annotation-driven validator="validator">
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:messages"/>
</bean>
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<property name="providerClass" value="org.hibernate.validator.HibernateValidator"/>
</bean>
<bean class="org.springframework.validation.beanvalidation.MethodValidationPostProcessor">
<property name="validator" ref="validator"/>
</bean>
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
<property name="defaultLocale" value="en" />
</bean>
Run Code Online (Sandbox Code Playgroud)
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.NotEmpty;
@Entity
public class JUser implements Officeable {
@Id
private Long id;
@Column(unique = true, nullable = false)
private String username;
private …
Run Code Online (Sandbox Code Playgroud) validation spring spring-mvc hibernate-validator spring-validator
我正在尝试向我的expressjs应用添加错误和通知功能.我以为通过电话来考虑
app.use(function (req, res, next) {
res.notice = function (msg) {
res.send([Notice] ' + msg);
}
});
Run Code Online (Sandbox Code Playgroud)
notice函数将附加到我的应用程序中的所有res对象,使我能够按如下方式使用它:
app.get('something', function (req, res) {
res.notice('Test');
});
Run Code Online (Sandbox Code Playgroud)
但是,上面的示例不起作用.有没有办法完成我想要做的事情?
我的问题如下:
Jackson desearlization:根上的两个键。如何打开其中一个并忽略另一个?
我希望在不使用包装类的情况下解决这个问题,如这个问题中所解决的。
我正在开发一个球衣客户端应用程序。我已经配置了与球衣集成的杰克逊数据绑定。
Map<Class<?>, Class<?>> mixins = new HashMap<Class<?>, Class<?>>();
mixins.put(Set.class, CollectionMixIn.class);
return new ObjectMapper()
.configure(SerializationFeature.WRAP_ROOT_VALUE, true)
.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false)
.setMixIns(mixins);
Run Code Online (Sandbox Code Playgroud)
民信接口:
@JsonRootName("items")
interface CollectionMixIn {
}
Run Code Online (Sandbox Code Playgroud)
服务器返回一个 json 响应,如下所示:
{"totalCount":6,"items":[{"id":62,"lat":30.2173,"lon":50.186405,"alt":0.0,"imageFileName":"DSC_0410 - Copy (3).JPG","imageFileSize":7671969,"imageFileSizeAsString":"7.32 MB"},{"id":65,"lat":30.2173,"lon":50.186405,"alt":0.0,"imageFileName":"DSC_0410 - Copy.JPG","imageFileSize":7671969,"imageFileSizeAsString":"7.32 MB"}]}
Run Code Online (Sandbox Code Playgroud)
我在 jersey 客户端的帮助下读取了上面的 json:
WebTarget target = webTarget.path("getPics");
target = target.queryParam("nodeId", 67);
Invocation.Builder builder = target.request(MediaType.APPLICATION_JSON_TYPE);
Set<PicsDetail> res = builder.get(Set.class);
Run Code Online (Sandbox Code Playgroud)
请注意,这PicsDetail
是我的 POJO。我想读一本PicsDetail
s集。但我面临这个例外:
Exception in thread "main" javax.ws.rs.ProcessingException: Error reading entity from input stream.
at …
Run Code Online (Sandbox Code Playgroud) 我开发了一个 Spring Web-MVC 应用程序。我的项目中有一些办公室。每个用户属于一个办公室。user.getOfficeType()
返回一个表示用户办公室类型的整数。如果 office 类型为 1,则用户属于 Office1 等。但是我想将经过身份验证的用户的 office 注入我的服务类:
class MyService{
@Autowired
Office currentOffice;
...
}
Run Code Online (Sandbox Code Playgroud)
我阅读了 Spring 文档。我需要一个会话范围的 bean 将它注入到我的服务类中。
applicationContext.xml :
<mvc:annotation-driven />
<tx:annotation-driven transaction-manager="hibernateTransactionManager"/>
<context:annotation-config />
<context:component-scan base-package="com.package.controller" />
<context:component-scan base-package="com.package.service" />
...
<bean id="office" class="com.package.beans.Office" scope="session">
<aop:scoped-proxy/>
</bean>
Run Code Online (Sandbox Code Playgroud)
我有Office
接口的三个实现。一旦用户请求资源,我想知道他的办公室。所以我需要将他的会话范围的 Office 注入我的服务类。但是我不知道如何根据用户的办公室来实例化它。请帮忙!
java ×3
spring ×3
spring-mvc ×3
c# ×2
javascript ×2
string ×2
validation ×2
.net ×1
annotations ×1
backup ×1
command-line ×1
database ×1
express ×1
hash ×1
hex ×1
jackson ×1
jersey ×1
json ×1
node.js ×1
pg-dump ×1
php ×1
postgresql ×1
prototype ×1
prototypejs ×1
sha256 ×1
spring-bean ×1
symfony ×1