我正在努力解决以下问题.使用javascript我想更改文件内容的字符集并将此内容显示给用户.
我有一个输入:文件表单.在改变时我正在阅读内容
$('#form input:file').change(function(event){
file = this.files[0];
reader = new FileReader();
reader.onload = function(event) {
result = event.target.result.replace(/\n/g,'<br />');
$('#filecontents').html(result);
});
reader.readAsText(file);
})
Run Code Online (Sandbox Code Playgroud)
该文件位于Windows-1251中.我想将文件的内容转换为另一种编码,然后将其呈现给用户.
这有可能用javascript实现吗?
问候
我有一组X和Y点来构建一个形状,我需要知道一个对象是否在其中,或者它的计算是什么?
X和Y坐标示例:
522.56055 2389.885
544.96 2386.3406
554.18616 2369.2385
535.21814 2351.396
497.5552 2355.8396
Run Code Online (Sandbox Code Playgroud)
我对数学并不是很好:(所以我希望得到一些支持,以了解它是如何完成的.
我到目前为止的例子,但似乎不太可靠:
private boolean isInsideShape(Zone verifyZone, Position object)
{
int corners = verifyZone.getCorners();
float[] xCoords = verifyZone.getxCoordinates();
float[] yCoords = verifyZone.getyCoordinates();
float x = object.getX();
float y = object.getY();
float z = object.getZ();
int i, j = corners - 1;
boolean inside = false;
for(i = 0; i < corners; i++)
{
if(yCoords[i] < y && yCoords[j] >= y || yCoords[j] < y && yCoords[i] >= y)
if(xCoords[i] …Run Code Online (Sandbox Code Playgroud) 我对IntelliJ IDEA的gradle集成以及gradle子项目到IDEA模块的映射感到困惑.
UPDATE
它iframe位于同一个域中,我尝试了以下代码,但没有一个有效:
myframe.document.getElementById("myform").submit();
parent.top.frames[0].document.forms[0].submit();
myframe.document.getElementById("myform").submit();
MyIFrame = document.getElementById("myframe");
myIFrame.getElementById("myform").submit();
Run Code Online (Sandbox Code Playgroud)
更新:
这是HTML:
<html>
<body>
<iframe frameborder="0" scrolling="no" width="530" height="298"
src="/iframe.php" name="myframe" id="myframe">
<p>iframes are not supported by your browser.</p>
</iframe><br />
<form action="/styles.css" method="post" id="form1">
<input type="text" name="input1" value=""/>
<input type="text" name="input2" value=""/>
<input type="button" value="test" onclick="submitFrame()">
<input type="submit" value="submit">
</form>
<script>
function submitFrame(){
var MyIFrame = document.getElementById("myframe");
var MyIFrameDoc = (MyIFrame.contentWindow || MyIFrame.contentDocument);
if (MyIFrameDoc.document) MyIFrameDoc = MyIFrameDoc.document;
MyIFrameDoc.getElementById("myform").submit(); // ## error
}
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
iframe.php:
<form method="post" …Run Code Online (Sandbox Code Playgroud) 我们有使用 OneToOne 注释和 PostgreSQL 的 Spring Boot 应用程序。
\n所属类别:
\n@Table(name = "PAYMENT")\npublic class PaymentDO {\n\n @Id\n @GeneratedValue(strategy = GenerationType.IDENTITY)\n @Column(name = "PAYMENT_ID", insertable = false, updatable = false, nullable = false)\n private Long paymentId;\n\n @OneToOne(mappedBy = "payment", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)\n private PaymentBatchJobDO paymentBatchJob;\n\n}\nRun Code Online (Sandbox Code Playgroud)\n所属类别:
\n@Table(name = "PAYMENT_BATCH_JOB")\npublic class PaymentBatchJobDO {\n\n @Id\n @Column(name="PAYMENT_ID", updatable = false, nullable = false)\n private Long paymentId;\n\n @OneToOne\n @PrimaryKeyJoinColumn(name = "PAYMENT_ID", referencedColumnName = "PAYMENT_ID")\n private PaymentDO …Run Code Online (Sandbox Code Playgroud) 在调试为什么我的@scheduled方法没有触发时,我将问题追溯到ScheduledAnnotationBeanPostProcessor.
当调用afterSingletonsInstantiated()后,applicationContent已经设置,因此不会调用finishRegistration().
然后onApplicationEvent()似乎永远不会被调用.contextRefresh事件正在作为我使用的调用的StartUpHouseKeeping类发布
@EventListener
public void onApplicationEvent(ContextRefreshedEvent event) { ... }
Run Code Online (Sandbox Code Playgroud)
如果我在afterSingletonsInstantiated()中坚持一个断点并手动调用finishRegistration()就可以正常工作.
我正在使用java配置而没有web.xml
AppInit.java
public class AppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
private static final Logger log = LoggerFactory.getLogger(AppInitializer.class);
private static final String[] NO_CACHE_URLS = new String[]{"*.appcache", "*.webapp", "/static/js/*", "/static/css/*", "/api/*", "/ping"};
public AppInitializer() {
log.info("** App Initializer **");
}
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
super.onStartup(servletContext);
}
@Override
protected WebApplicationContext createRootApplicationContext() {
// ((ConfigurableEnvironment)context.getEnvironment()).addActiveProfile(_env.getProperty("env", "local"));
return super.createRootApplicationContext();
}
@Override …Run Code Online (Sandbox Code Playgroud) 我在我的项目中使用了 querydsl、hibernate 和 spring data jpa。我编写了这个本机查询并且工作正常。但是我如何在 Querydsl 中编写这个查询。
List<OpenChart> openChartList = (List<OpenChart>) getEntityManager()
.createNativeQuery( "select * from (select * from open_chart order by id desc ) open_chart where user_id="+userId+" group by patient_chart_id order by id",OpenChart.class).getResultList();
Run Code Online (Sandbox Code Playgroud) 我看到了有关如何将 Google Analytics/ GA 动态添加到页面中的各种指南,例如单页面应用程序/ SPA。
我该如何做相反的事情,即用户单击一个按钮,Google Analytics 就会从该页面完全删除,而无需加载整个页面?
https://developers.google.com/analytics/devguides/collection/gtagjs/user-opt-out上的说明建议设置
window['ga-disable-GA_MEASUREMENT_ID'] = true;
Run Code Online (Sandbox Code Playgroud)
我认为这样做没有帮助,因为页面指出
必须在调用 gtag() 之前设置此窗口属性
我想使用 OAuth 2 通过 Spring Security 保护我的应用程序。但是,我不希望服务器重定向传入的未经授权的请求,而是使用 HTTP 401 进行响应。这可能吗?
示例:此代码将请求重定向到默认登录页面。
应用程序属性
spring.security.oauth2.client.registration.google.client-id=...
spring.security.oauth2.client.registration.google.client-secret=...
Run Code Online (Sandbox Code Playgroud)
验证配置文件
@Configuration
public class AuthConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/secured/**").authenticated()
.anyRequest().permitAll()
.and()
.oauth2Login();
// /sf/ask/2220020981/
// deos not work
// .and()
// .formLogin().successHandler((request, response, authentication) -> {});
}
}
Run Code Online (Sandbox Code Playgroud) 如果我使用这样的东西懒惰加载我的一些css文件,是否可以添加2个css文件或者它只能加载1?
<script>
var cb = function() {
var l = document.createElement('link');
l.rel = 'stylesheet';
l.href = 'yourCSSfile.css';
var h = document.getElementsByTagName('head')[0];
h.parentNode.insertBefore(l, h);
};
var raf = requestAnimationFrame || mozRequestAnimationFrame ||
webkitRequestAnimationFrame || msRequestAnimationFrame;
if (raf) {
raf(cb)
} else {
window.addEventListener('load', cb);
}
</script>
Run Code Online (Sandbox Code Playgroud) 因此,我有一个包含一些输入(名字和姓氏、用户名、生日、密码和电子邮件)的表单,其中包含一些我制作的验证条件,例如:
function checkfnlname(field) {
curr = document.getElementById(field).value;
if ( curr.length > 0) {
updateCSSClass(field, 1);
return true;
}
else {
updateCSSClass(field, 0);
return false;
}}
Run Code Online (Sandbox Code Playgroud)
这会改变它的颜色并返回 true 。我使用onKeyUp="". 现在我想要做的是禁用提交按钮,直到所有字段都已完成并由那里的功能验证。我写了这个函数:
function formvalid() {
if (checkfnlname('fname') && && (all other fields)) {
document.getElementByID("submitinput").disabled = false;
}
else {
document.getElementByID("submitinput").disabled = true;
}
return 1;}
Run Code Online (Sandbox Code Playgroud)
但我不知道如何/在哪里调用它。(我尝试了很多我发现的东西,但没有任何效果)这是正确的方法吗?如果是这样,我该如何调用这个函数?
如何通过所有多术语搜索仅获得过滤后的匹配结果。我有这个示例表,其中 titleid 是映射 int 字段,personid 是关键字:
titleid:1,personid:a
titleid:3,personid:a
titleid:1,personid:b
titleid:2,personid:b
titleid:1,personid:c
titleid:5,personid:c
Run Code Online (Sandbox Code Playgroud)
预期结果是:
titleid:1
Run Code Online (Sandbox Code Playgroud)
使用如下示例查询:
{query:
{bool:
{filter:
{must:[
{terms : {fields: {personid:[a,b,c]}}
]
}}}}
Run Code Online (Sandbox Code Playgroud)
我有以下结果:
titleid: 1,2,3,5
Run Code Online (Sandbox Code Playgroud)
也许这会有所帮助,我在 sql 中进行了查询并得到了预期的结果。我所做的是要求查询给出与搜索参数数量匹配的 titleid 总和。这只是为了更自我解释,这个想法是使用elasticsearch。
select titleid
from (
select count(titleid) as title_count, titleid
from table1
where personid in ('a','b','c')
group by titleid
) as vw
where title_count = 3
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用记事本++选择一个新行并将其替换为“','”,以便我可以在PHP中将其用作数组,然后对其进行处理,但我不知道在该中使用什么正则表达式搜索和替换表格。
下面是我所拥有的
Tunneller
Turf Accountant
Turkey Farmer
Turner
Tutor
Typesetter
Typewriter Engineer
Typist..
Run Code Online (Sandbox Code Playgroud)
你想要得到像这样的东西 - 类似数组的语法来输入我的 php 文档。
$array = ['Tunneller','Turf','Accountant','TurkeyFarmer','Turner','Tutor','Typesetter','Typewriter Engineer','Typist']
Run Code Online (Sandbox Code Playgroud)
谢谢。
javascript ×5
java ×4
hibernate ×2
spring ×2
analytics ×1
arrays ×1
coordinates ×1
css ×1
encoding ×1
filereader ×1
form-submit ×1
forms ×1
gradle ×1
gtag.js ×1
html ×1
iframe ×1
jts ×1
lazy-loading ×1
notepad++ ×1
oauth-2.0 ×1
php ×1
postgresql ×1
querydsl ×1
submit ×1
validation ×1