我知道有很多关于此的问题,但我无法让这个工作:
我想在multipart/form-data中将文件从输入上传到服务器
我尝试了两种方法.第一:
headers: {
'Content-Type': undefined
},
Run Code Online (Sandbox Code Playgroud)
这导致例如图像
Content-Type:image/png
Run Code Online (Sandbox Code Playgroud)
而它应该是multipart/form-data
和另外一个:
headers: {
'Content-Type': multipart/form-data
},
Run Code Online (Sandbox Code Playgroud)
但这要求一个边界标题,我相信不应该手动插入...
什么是解决这个问题的干净方法?我读过你能做到的
$httpProvider.defaults.headers.post['Content-Type'] = 'multipart/form-data; charset=utf-8';
Run Code Online (Sandbox Code Playgroud)
但我不希望我的所有帖子都是multipart/form-data.默认值应为JSON
我正在创建一个有角度的邮箱.当发送消息的弹出窗口关闭时,我需要保存草稿消息.
我知道有一些选择:
scope.$on("$destroy", function () { saveMessage() });
Run Code Online (Sandbox Code Playgroud)
和:
$mdDialog.show(...).finaly(function(){ saveMessage() });
Run Code Online (Sandbox Code Playgroud)
但两者都不足够:
所以我正在寻找在弹出窗口实际关闭之前调用函数的方法.就像是scope.$on("$mdDialogBeforeClose", function () { saveMessage() });
另一个选择是挂钩每个关闭事件.看起来很难看,但可能是解决方案.在这种情况下,我需要听取转义按钮并在弹出窗口外单击(Altough我可能会禁用该功能)...
有更好的想法吗?
谢谢!
编辑:
另外一个问题:如何捕获escape-keypress事件?我试过<md-dialog aria-label="List dialog" ng-keypress="keyPress($event)">但它甚至没有被触发......
ondestroy angularjs oncloselistener angular-material mddialog
我有一个角度应用程序,根据设置,它与 Tomcat 上的 REST API 或 Jetty 上的 REST API 进行通信。角度应用程序本身与战争托管在同一个 tomcat/jetty 上。
Tomcat 设置前面可能有 Apache(取决于客户端)
该应用程序需要使用 base64 图像(通过 css 加载),但现在,如果它托管在服务器上,我会收到以下错误:
Refused to load the image 'data:image/png;base64,...' because it violates the following Content Security Policy directive: "default-src https:". Note that 'img-src' was not explicitly set, so 'default-src' is used as a fallback.
Run Code Online (Sandbox Code Playgroud)
所以我做了什么:在index.html中,我设置了:
<meta http-equiv="Content-Security-Policy"
content="default-src https: http:; script-src 'self' 'unsafe-inline' 'unsafe-eval' https: http:; style-src http: https: 'unsafe-inline'; img-src 'self' data: https:; connect-src http: https: ws:;">
Run Code Online (Sandbox Code Playgroud)
在手动 Spring 过滤器中,我设置了:
httpServletResponse.setHeader("Content-Security-Policy", …Run Code Online (Sandbox Code Playgroud) 我正在使用杰克逊 2.7.0
encodingType当使用一些新值更新现有对象时,我试图忽略:
ObjectMapper om = new ObjectMapper();
om.readerForUpdating(message).readValue(messageSubset);
Run Code Online (Sandbox Code Playgroud)
message包含 的值encodingType。
messageSubset(JSON 字符串)不包含 的条目(无键值)encodingType。
我尝试过的:
om.setSerializationInclusion(Include.NON_EMPTY);@JsonIgnoreProperties(ignoreUnknown = true)@JsonIgnoreProperties(value = { "encodingType" })@JsonInclude(Include.NON_EMPTY)@JsonInclude(Include.NON_NULL)@JsonInclude(Include.NON_EMPTY)@JsonInclude(Include.NON_NULL)@JsonIgnore@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)不是以上工作!有什么帮助吗?
我想这与 readerForUpdating 和/或其中之一正在更新这一事实有关。
Stack Overflow 社区大家好!
\n\n我有一个 Maven - java 项目,需要使用 jenkins 管道构建。\n为此,我已使用 docker 映像配置了作业maven:3.3.3。一切正常,除了我使用的事实ru.yandex.qatools.embed:postgresql-embedded. 这在本地有效,但在 jenkins 上它抱怨启动 Postgres:
2019-02-08 09:31:20.366 WARN 140 --- [ost-startStop-1] r.y.q.embed.postgresql.PostgresProcess: Possibly failed to run initdb: \n\ninitdb: cannot be run as root\n\nPlease log in (using, e.g., "su") as the (unprivileged) user that will own the server process.\n\n2019-02-08 09:31:40.999 ERROR 140 --- [ost-startStop-1] r.y.q.embed.postgresql.PostgresProcess: Failed to read PID file (File \'/var/.../target/database/postmaster.pid\' does not exist)\n\njava.io.FileNotFoundException: File \'/var/.../target/database/postmaster.pid\' does not exist\nRun Code Online (Sandbox Code Playgroud)\n\n显然,出于安全原因,Postgres 不允许以超级用户权限运行。
\n\n …我通过LDAP为特定应用程序添加用户,使用spring制作.
虽然这适用于大多数情况,但在某些情况下,它不起作用......
检索我使用的用户:
public class LdapUserServiceImpl implements ILdapUserService {
@Override
public List<LdapUserVO> getUserNamesByQuery(String query) {
return ldapTemplate.search(
query().countLimit(15)
.where("objectClass").is("user")
.and("sAMAccountName").isPresent()
.and(query()
.where("sAMAccountName").like("*" + query + "*")
.or("sAMAccountName").is(query)
.or("displayName").like("*" + query + "*")
.or("displayName").is(query))
,
new AttributesMapper<LdapUserVO>() {
public LdapUserVO mapFromAttributes(Attributes attrs) throws NamingException {
LdapUserVO ldapUser = new LdapUserVO();
Attribute attr = attrs.get(ldapUserSearch);
if (attr != null && attr.get() != null) {
ldapUser.setUserName(attr.get().toString());
}
attr = attrs.get("displayName");
if (attr != null && attr.get() != null) {
ldapUser.setDisplayName(attr.get().toString());
}
return ldapUser; …Run Code Online (Sandbox Code Playgroud) 我有一个 postgres 列 double[]: {100, 101, 102}。
我想将每个元素除以 10,所以结果应该是 {10.0, 10.1, 10.2}。
我只找到了带有 for 语句的解决方案,但是如何通过简单的查询来实现这一点?(我需要通过liquibase更新)
另一种方法是编写 Java 迁移,但我更喜欢简单的查询......
提前致谢!
更新:
出现的第二个问题是:
当通过 Liquibase java-migration 脚本执行此操作时,您会得到一个liquibase.database.jvm.JdbcConnection(through liquibase.change.custom.CustomTaskChange),它当然不支持 postgres-arrays =/。
如何以这种方式处理数组?(我使用liquibase-core 3.5.5)
angularjs ×3
java ×2
postgresql ×2
spring ×2
arrays ×1
docker ×1
file-upload ×1
http ×1
http-headers ×1
jackson ×1
jenkins ×1
json ×1
ldap ×1
ldap-client ×1
ldap-query ×1
liquibase ×1
mddialog ×1
objectmapper ×1
ondestroy ×1
root ×1
spring-ldap ×1
tomcat ×1