我有一个基本的HTML表单,我可以从中获取一些我在Firebug中检查的信息.
我唯一的问题是我试图在将文件数据发送到服务器之前对文件数据进行base64编码,然后需要将该文件数据保存到数据库中.
<input type="file" id="fileupload" />
Run Code Online (Sandbox Code Playgroud)
在Javascript + jQuery中:
var file = $('#fileupload').attr("files")[0];
Run Code Online (Sandbox Code Playgroud)
我有一些基于可用的javascript的操作:.getAsBinary(),. getAsText(),. getAsTextURL
但是这些都没有返回可插入的可用文本,因为它们包含不可用的"字符" - 我不希望在我上传的文件中出现"回发",我需要有多个表单来定位特定对象,所以这很重要获取文件并以这种方式使用Javascript.
我应该如何获得文件,以便我可以使用一个广泛可用的Javascript base64编码器!?
这是我在的地方:
<input type="file" id="fileuploadform" />
<script type="text/javascript>
var uploadformid = 'fileuploadform';
var uploadform = document.getElementById(uploadformid);
/* method to fetch and encode specific file here based on different browsers */
</script>
Run Code Online (Sandbox Code Playgroud)
跨浏览器支持的几个问题:
var file = $j(fileUpload.toString()).attr('files')[0];
fileBody = file.getAsDataURL(); // only works in Firefox
Run Code Online (Sandbox Code Playgroud)
此外,IE不支持:
var file = $j(fileUpload.toString()).attr('files')[0];
Run Code Online (Sandbox Code Playgroud)
所以我必须替换为:
var element …Run Code Online (Sandbox Code Playgroud) 试图让我的项目更新到MVC3,我找不到的东西:
我有一个简单的ENUMS数据类型:
public enum States()
{
AL,AK,AZ,...WY
}
Run Code Online (Sandbox Code Playgroud)
在我的包含此数据类型的模型视图中,我想将其用作DropDown/SelectList:
public class FormModel()
{
public States State {get; set;}
}
Run Code Online (Sandbox Code Playgroud)
非常简单:当我为这个分部类使用自动生成视图时,它忽略了这种类型.
我需要一个简单的选择列表,当我通过我的AJAX - JSON POST方法点击提交和处理时,将枚举的值设置为所选项.
而不是视图(???!):
<div class="editor-field">
@Html.DropDownListFor(model => model.State, model => model.States)
</div>
Run Code Online (Sandbox Code Playgroud)
提前感谢您的建议!
我们有一个Spring over WebSockets连接,我们正在传递一个CONNECT框架:
CONNECT\naccept-version:1.2\nheart-beat:10000,10000\n\n\u0000
Run Code Online (Sandbox Code Playgroud)
处理程序确认哪个,启动一个新会话,然后返回:
CONNECTED
version:1.2
heart-beat:0,0
Run Code Online (Sandbox Code Playgroud)
但是,我们想要心跳,以便我们可以保持WebSocket开放.我们没有使用SockJS.
我介绍了Spring Message Handler:
StompHeaderAccessor [headers={simpMessageType=CONNECT, stompCommand=CONNECT, nativeHeaders={accept-version=[1.2], heart-beat=[5000,0]}, simpSessionAttributes={}, simpHeartbeat=[J@5eba717, simpSessionId=46e855c9}]
Run Code Online (Sandbox Code Playgroud)
在获得heart-beat(本机标头)之后,它设置看起来像内存地址的内容simpHeartbeat=[J@5eba717, simpSessionId=46e855c9}]
值得注意的是,经纪人验证后:
Processing CONNECT session=46e855c9 (这里的sessionId与simpSessionId不同)?
在运行早期的TRACE调试时,我看到了一个通知"调度心跳......"或者那种效果......虽然我现在没有看到它?
知道发生了什么事吗?
谢谢
我在文档中找到了解释:
来自SockJS任务调度程序的线程池的SockJS任务计划程序统计信息,用于发送检测信号.请注意,在STOMP级别协商心跳时,将禁用SockJS心跳.
SockJS的心跳是否与STOMP心跳不同?
试图让我的应用程序运行FriendlyId gem(版本4.0.1)
我觉得我在错误的顺序做这个,但我想去掉引号之前我friendly_id金属块产生创造了新的记录时.但我认为在生成id之后调用normalize_friend_id方法.
我已将以下内容添加到我的模型中:
class Team < ActiveRecord::Base
extend FriendlyId
friendly_id :name, :use => :slugged
def normalize_friendly_id(string)
super.gsub("\'", "")
end
end
Run Code Online (Sandbox Code Playgroud) 我想用一个custom authentication filter:
我希望能够使用此安全上下文持有者来获取有关当前请求用户正确处理其请求的详细信息.
@RequestMapping(value = "/simple", method = RequestMethod.POST)
@ResponseBody
@Transactional
@Preauthorize(...)
public String simple(){
//collect the user's current details from the getPrinciple() and complete the transaction...
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
return "Simple";
}
Run Code Online (Sandbox Code Playgroud)
我以前用XML做过这样的事情:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:security="http://www.springframework.org/schema/security"
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-3.2.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.2.xsd">
<security:global-method-security
secured-annotations="enabled" />
<security:http pattern="/**"
auto-config="true" disable-url-rewriting="true" use-expressions="true">
<security:custom-filter ref="authenticationTokenProcessingFilter"
position="FORM_LOGIN_FILTER" />
<security:intercept-url pattern="/authenticate"
access="permitAll" />
<security:intercept-url pattern="/secure/**"
access="isAuthenticated()" />
</security:http>
<bean id="CustomAuthenticationEntryPoint" class="org.foo.CustomAuthenticationEntryPoint" />
<bean class="org.foo.AuthenticationTokenProcessingFilter" id="authenticationTokenProcessingFilter">
<constructor-arg ref="authenticationManager" />
</bean> …Run Code Online (Sandbox Code Playgroud) 我正在使用Spring Data,我创建了包含在"AbstractEntity"中的实体,所有对象都扩展为获取基本列
AbstractEntity:
@MappedSuperclass
public abstract class AbstractEntity implements Serializable{
@Temporal(TemporalType.TIMESTAMP)
@Column(nullable = false)
private Date CreatedDate;
@PrePersist
protected void onCreate() {
UpdatedDate = CreatedDate = new Date();
}
...
Run Code Online (Sandbox Code Playgroud)
和我的对象/实体
@Entity
public class Trade extends AbstractEntity {
Run Code Online (Sandbox Code Playgroud)
当我尝试使用我的存储库创建方法时 findByCreatedDateAfter(Date date)
我得到一个例外,无法找到该列......?
public interface TradeRepository extends CrudRepository<Trade, Long>{
public List<Trade> findByCreatedDateAfter(Date date);
}
Run Code Online (Sandbox Code Playgroud)
它编译(如果我使用某些capitolization)但是试图映射查询,我得到:
Caused by: java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name [createdDate] on this ManagedType [streaming.data.AbstractEntity]
Run Code Online (Sandbox Code Playgroud)
我还想返回sum(amount)此期间的金额列之一.
我正在尝试yarn package针对我的Electron应用程序运行。
我进入“代码签名”步骤,并提示管理员访问我的“系统”钥匙串。
我输入我的凭据,并立即提示输入凭据以再次访问系统钥匙串。
我已经检查并升级到最新的XCode,并且我的Apple Developer Code-Signing证书已安装(?),并且我已经检查并且终端xcodebuild -version显示以下内容:
Xcode 9.2
Build version 9C40b
Run Code Online (Sandbox Code Playgroud)
终端的最后输出线是:
electron-builder 19.31.1
No native production dependencies
Packaging for darwin x64 using electron 1.7.3 to release/mac
Signing app (identity: 068C71CA6XXXXXXXXXXXXX gdb-cert)
Run Code Online (Sandbox Code Playgroud)
我不知道这是否是identity我的钥匙串中正确的匹配项-但gdb-cert看起来不正确吗?
-更新
我必须为所有框架项目输入大约2打用户名/密码组合。必须有一种始终允许的方式吗?
我有一些非常持久的 HTTP 调用,我需要结果。
如何为这些类型的调用延长服务器端的超时时间。请注意,这与服务器的Session-Timeout定义不同web.xml。
我注意到 JAX-RS 有一个@Timeout符号,但我不知道如何使用它,或者它是否适用于这种类型的配置。
我的电话设置如下:
@Path("/path/")
public class BulkCreate {
@Path("/path")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response query(@QueryParam("token") String token,
BulkCreateObject[] objects) {
....
}
}
Run Code Online (Sandbox Code Playgroud)
我不能使用@Suspend或使它们完全异步。
我没有开始设置这个项目,所以我不知道启用这些接口还需要哪些其他项目,除了它们可以工作,但我不知道在哪里设置扩展超时。
我将客户端请求的超时设置为很长时间,但请求仍然超时(我相信在服务器端)并在大约 2-3 分钟后向客户端抛出“超时异常”?
我在此处的文档中找不到任何内容。
我正在尝试开始使用react-css-modulesw/ babel-plugin-react-css-modules。目前我有一个运行 react的电子锻造应用程序。
我的.compilerc看起来如下:
{
"env": {
"development": {
"application/javascript": {
"presets": [
["env", { "targets": { "electron": "2.0.0" } }],
"es2015", "stage-0", "react"
],
"plugins": ["transform-decorators-legacy", "transform-runtime"],
"sourceMaps": "inline"
}
},
"production": {
"application/javascript": {
"presets": [
["env", { "targets": { "electron": "2.0.0" } }],
"es2015", "stage-0", "react"
],
"plugins": ["transform-decorators-legacy", "transform-runtime"],
"sourceMaps": "none"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的理解.compilerc类似于.babelrc(我没有.babelrc文件),请参阅:electron-compile(electron-forge 使用的 - 我猜)
但是,.css …
babeljs electron react-css-modules electron-forge babel-plugin-react-css-modules
我一直在关注Spring Boot的开发,有时在初始版本0.0.5-BUILD-SNAPSHOT和我正在使用的当前版本之间,1.0.0.RC1我不再运行我的import.sql脚本了.
这是我的配置LocalContainerEntityManager和JpaVendorAdapter
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
DataSource dataSource, JpaVendorAdapter jpaVendorAdapter) {
LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean();
lef.setDataSource(dataSource);
lef.setJpaVendorAdapter(jpaVendorAdapter);
lef.setPackagesToScan("foo.*");
return lef;
}
@Bean
public JpaVendorAdapter jpaVendorAdapter() {
HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
hibernateJpaVendorAdapter.setShowSql(true);
hibernateJpaVendorAdapter.setGenerateDdl(true);
hibernateJpaVendorAdapter.setDatabase(Database.POSTGRESQL);
return hibernateJpaVendorAdapter;
}
Run Code Online (Sandbox Code Playgroud)
有趣的hibernate.hbm2ddl.auto似乎还在运行,我认为这是我的定义的一部分SpringBootServletInitializer
@Configuration
@ComponentScan
@EnableAutoConfiguration
public class Application extends SpringBootServletInitializer {
Run Code Online (Sandbox Code Playgroud)
但是,我还注意到生成的表格不再有下划线并在生成时改变了它们的形状?
但是,这可能是更新我的org.postgresql版本的结果:
先前:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.2-1004-jdbc41</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
现在:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.3-1100-jdbc41</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我也不得不改变 …
spring ×2
spring-data ×2
babel-plugin-react-css-modules ×1
babeljs ×1
base64 ×1
c# ×1
electron ×1
file-upload ×1
friendly-id ×1
hibernate ×1
html ×1
javascript ×1
jboss ×1
razor ×1
resteasy ×1
spring-boot ×1
stomp ×1
timeout ×1
xcode ×1