I am working on an Android project in which I am using the 'SuperSlim' framework for creating a grid view of Notes(Custom class) along with data to be displayed. Notes in the Database have a many-to-one relationship with Sections(Custom class). And Sections in turn have many-to-one relationship with Canvas.
All information for section, notes is dynamically retrieved from server as a List.
Now I am at the point, where I am able to display a Grid view of Sections, and …
java android android-gridview android-recyclerview superslim
我正在开发一个Java项目,其中有一个HTML编辑器,用户可以在html编辑器(ckeditor)中输入文本,实际的HTML文本保存在数据库中.
现在,当用户下次再来,并编辑相同的文本时,我想通过比较它与数据库来显示两者之间的差异.
我面临的最重要的问题是,即使任何比较器工具知道Italic的样式已经变为Bold,比较器的输出也strike-throughs就是单词Italic和节目Bold插入代替它.
但这并不能解释实际编辑的意图或行动.意图/行动是用户从Italic到Bold.我正在寻找的是一个工具,它不是显示Italic这个词被删除而Bold被添加而不是代替那个,它会向我显示Italic首先是删除的Bold 单词/句子以及用单词/句子替换.
我希望我的意思很明确.我一直在努力实现这一目标.我试过diff_match_patch,daisydiff等,没有任何帮助.
我的试验:
/*
String oldTextHtml = mnotes1.getMnotetext();
String newTextHTML = mnotes.getMnotetext();
oldTextHtml = oldTextHtml.replace("<br>","\n");
oldTextHtml = Jsoup.clean(oldTextHtml, Whitelist.basic());
oldTextHtml = Jsoup.parse(oldTextHtml).text();
newTextHTML = newTextHTML.replace("<br>","\n");
newTextHTML = Jsoup.clean(newTextHTML,Whitelist.basic());
newTextHTML = Jsoup.parse(newTextHTML).text();
diff_match_patch diffMatchPatch = new diff_match_patch();
LinkedList<diff_match_patch.Diff> deltas = diffMatchPatch.diff_main(oldTextHtml, newTextHTML);
diffMatchPatch.diff_cleanupSemantic(deltas);
newText += diffMatchPatch.diff_prettyHtml(deltas);
groupNoteHistory.setWhatHasChanged("textchange");
groupNoteHistory.setNewNoteText(newText);
noEdit = true;
*/
List<String> oldTextList = Arrays.asList(mnotes1.getMnotetext().split("(\\.|\\n)"));
List<String> newTextList = Arrays.asList(mnotes.getMnotetext().split("(\\.|\\n)"));
if (oldTextList.size() == newTextList.size()) …Run Code Online (Sandbox Code Playgroud) 我正在开发一个Spring-MVC项目,我目前正在使用Timeline功能.我有一个基本的基础设施正在进行中,但目前,我正在处理映射,以及如何避免为时间轴功能创建重复项.
情况:
在我们的工具中,有GroupSection,它与GroupNote具有一对多的映射.GroupNote对象具有"附件","历史记录"的一对多映射.
这个时间线功能是什么?
在时间轴功能中,任何用户都可以在任何时间点跳转并检查GroupSection,GroupNotes,附件和历史记录的内容.
我打算如何实施它?
我在上述每个对象中都有4个变量来处理它.它们是Date SavedDate,boolean initialNote,boolean noteModified,boolean latestNote.
除此之外,每个GroupNote都有一个自我加入,很快就会解释它.
现在,每次修改注释时,修改后的标志都设置为true.在晚上,我运行一个方法,它检查所有修改过的对象,并且只有在修改了对象时,它才会为Object创建一个重复的实例,将新的Date放入其中,将其标记为最新的,并保留它.
这样,我可以加载给定日期的所有对象.对于正常的日常使用latest,将加载所有标记为的笔记.
每当为持久性创建一个新对象时,它就会与旧对象自行连接Cascade.Remove.这样做的是,如果用户返回并从2015年移除对象,则所有后续对象也将被删除.这给了时间就像行为.
问题:
现在,如果修改了GroupSection,那么我将创建一个GroupSection实例并通过从修改后的GroupSection复制属性来保留它,并将其标记为最新.
现在,GroupSection持有的Notes没有被修改,但是如果我不创建它的重复条目,那么我将不会在前端看到任何Notes加载.但我想避免这种情况.我怎样才能做到这一点?
最后代码:
GroupSection模型:
@Entity
@Table(name = "membersection")
public class GroupSection {
@Column(name = "section_save_date", columnDefinition = "date")
private Date secnSavedDate;
@Column(name = "initial_section", columnDefinition = "boolean default true")
private boolean initialSection;
@Column(name = "section_modified", columnDefinition = "boolean default false")
private boolean sectionModified;
@Column(name = "latest_section", columnDefinition = "boolean default false")
private …Run Code Online (Sandbox Code Playgroud) 我正在 Apache JMeter 中对我们的应用程序进行压力测试。
我想到了调用 register user 方法将用户添加到数据库中。但如果电子邮件已经存在,则不会发生数据库操作。
如何在正文数据中添加随机数?或者是否有其他方法可以对与数据库连接的应用程序进行压力测试?
控制器代码:
@RequestMapping(value = "/person/add", method = RequestMethod.POST)
public String addPerson(@ModelAttribute("person") Person person, BindingResult bindingResult) {
System.out.println("Person add called"+person.getUsername());
person.setUsername(this.stripHTML(person.getUsername()));
int personId = this.personService.addPerson(person);
if (!(personId == 0)) {
Person person1 = this.personService.getPersonById(personId);
Collection<GrantedAuthority> authorities = new ArrayList<>();
authorities.add(new SimpleGrantedAuthority("ROLE_USER"));
Authentication authentication = new UsernamePasswordAuthenticationToken(person1, null, authorities);
SecurityContextHolder.getContext().setAuthentication(authentication);
return "redirect:/canvaslisting";
} else {
return "redirect:/";
}
}
Run Code Online (Sandbox Code Playgroud) 我正在开发一个JavaFX应用程序,它包含很少的html,css,JS文件,这些文件由内部webkit浏览器呈现.现在,问题是我们在JavaFX提供的webkit浏览器中没有得到平滑渲染的CSS动画,但Firefox或chrome中的相同代码相当平滑.
此外,没有持久性可用(目前在Java中使用变量,并通过JS进行持久性通信).
我正在寻找的是有任何方法来集成一些无头浏览器,或一些设置,使CSS动画更顺畅.我遇到的唯一问题是JxBrowser,但对于个人使用来说太昂贵了.
代码:
public class Main extends Application {
private Scene scene;
MyBrowser myBrowser;
String completeText = "";
@Override
public void start(Stage primaryStage) throws Exception{
primaryStage.setTitle("Frontend");
java.net.CookieManager manager = new java.net.CookieManager();
java.net.CookieHandler.setDefault(manager);
myBrowser = new MyBrowser();
scene = new Scene(myBrowser, 1080, 1920);
primaryStage.setScene(scene);
primaryStage.setFullScreen(true);
primaryStage.show();
// @ being the escape character
scene.setOnKeyTyped(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
String text = event.getCharacter();
if (text.equals("0")) {
String tempText = completeText;
completeText = "";
processText(tempText);
}else { …Run Code Online (Sandbox Code Playgroud) 我正在开发一个基于Spring-MVC的应用程序,我们使用Spring-Security进行登录,授权.我们之前使用的是版本3.2.5,升级是4.1.1.升级后,登录机制会因发送的用户名为空而中断.我不知道出了什么问题.你能帮忙的话,我会很高兴.
securityApplicationContext.xml:
<security:http pattern="/resources/**" security="none"/>
<security:http create-session="ifRequired" use-expressions="true" auto-config="false" disable-url-rewriting="true">
<security:form-login login-page="/login" login-processing-url="/j_spring_security_check" default-target-url="/dashboard" always-use-default-target="false" authentication-failure-url="/denied" />
<!--<security:remember-me key="_spring_security_remember_me" user-service-ref="userDetailsService" token-validity-seconds="1209600" data-source-ref="dataSource"/>-->
<security:logout delete-cookies="JSESSIONID" invalidate-session="true" logout-url="/j_spring_security_logout"/>
<!-- <security:intercept-url pattern="/**" requires-channel="https"/> -->
<security:intercept-url pattern="/j_spring_security_check" access="permitAll" />
<security:port-mappings>
<security:port-mapping http="8080" https="8443"/>
</security:port-mappings>
<security:logout logout-url="/logout" logout-success-url="/" success-handler-ref="myLogoutHandler"/>
<security:session-management session-fixation-protection="migrateSession">
<security:concurrency-control session-registry-ref="sessionRegistry" max-sessions="5" expired-url="/login"/>
</security:session-management>
<security:csrf disabled="true"/>
</security:http>
<security:authentication-manager alias="authenticationManager">
<security:authentication-provider user-service-ref="LoginServiceImpl">
<security:password-encoder ref="encoder"/>
</security:authentication-provider>
</security:authentication-manager>
<beans:bean id="encoder"
class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder">
<beans:constructor-arg name="strength" value="11" />
</beans:bean>
<beans:bean id="daoAuthenticationProvider"
class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
<beans:property name="userDetailsService" ref="LoginServiceImpl"/>
<beans:property name="passwordEncoder" ref="encoder"/>
</beans:bean> …Run Code Online (Sandbox Code Playgroud) 我正在使用Hibernate的Spring MVC应用程序.
在JSP页面中,我有一个函数列出了存储在数据库中的值(当前所有的值).
我编写了一个方法,其中列表仅限于JSP文件中传递的ID.我让HQL查询正常工作,所以我知道它是根据ID作为参数检索数据.
现在,我想在控制器中使用此方法.为此,我必须将ID参数传递给列表,因此在控制器端调用该函数,该函数将根据该ID检索列表.
不幸的是我不知道如何从JSP文件传递参数.
JSP文件:
<c:url var="addAction" value="/note/add" ></c:url>
<form:form action="${addAction}" commandName="notices">
<table>
<c:if test="${!empty notices.notetext}">
<tr>
<td>
<form:label path="noticesid">
<spring:message text="noticesid"/>
</form:label>
</td>
<td>
<form:input path="noticesid" readonly="true" size="8" disabled="true" />
<form:hidden path="noticesid" />
</td>
</tr>
</c:if>
<tr>
<td>
<form:label path="notetext">
<spring:message text="notetext"/>
</form:label>
</td>
<td>
<form:input path="notetext" />
</td>
</tr>
<tr>
<td>
<form:label path="notetag" >
<spring:message text="notetag"/>
</form:label>
</td>
<td>
<form:input path="notetag"/>
</td>
</tr>
<tr>
<td>
<form:label path="notecolor">
<spring:message text="notecolor"/>
</form:label>
</td>
<td>
<form:input path="notecolor" />
</td> …Run Code Online (Sandbox Code Playgroud) 我正在开发一个Java应用程序,在该应用程序中我试图从下载的InputStream中创建一个多部分文件。不幸的是,它不起作用并且多部分文件为空。我在将 saveFile 复制到 Multipart 之前检查了磁盘上的大小,它具有正确的大小、属性和内容。
我在转换中做错了什么,没有堆栈跟踪,因为我正在捕获它。
代码 :
// InputStream contains file data.
byte[] bytes = IOUtils.toByteArray(inputStream);
File file = new File(msg + "temp");
if (file.exists() && file.isDirectory()) {
OutputStream outputStream = new FileOutputStream(new File(msg + "temp" + "/" +
groupAttachments.getFileName()));
outputStream.write(bytes);
outputStream.close();
}
java.io.File savedFile = new java.io.File(msg + "temp" + "/" +
groupAttachments.getFileName());
DiskFileItem fileItem = new DiskFileItem("file", "text/plain", false,
savedFile.getName(), (int) savedFile.length(), savedFile.getParentFile());
fileItem.getOutputStream();
MultipartFile multipartFile = new CommonsMultipartFile(fileItem);
System.out.println("Saved file size is "+savedFile.length());
if (multipartFile.isEmpty()) { …Run Code Online (Sandbox Code Playgroud) 我正在研究在tomcat上运行的Spring-MVC应用程序,我想在其中使用Google驱动器功能.我尝试在我的本地机器上使用服务帐户,我没有遇到任何问题.但是当我在服务器上上传代码时,浏览器URL不会被打开.然后我想,我不应该使用服务帐户,我应该使用普通的网络应用程序帐户.现在,当我这样做时,我得到一个redirect_uri_mismatch.
我不明白一件事,我在流程中设置重定向URL,在JSON中,为什么它会获得带有随机端口号的redirect_url.如果我更改浏览器URL中的端口号,它可以正常工作.但仍然在服务器上它不会打开浏览器URL,我可以在tomcat日志中看到它,但该死的东西不会打开URL.
以下是我在Google应用中的重定向网址:
http://localhost/authorizeuser
http://localhost:8080/
http://localhost:8080
http://localhost
http://localhost:8080/Callback
https://testserver.net/Callback
http://testserver.net/Callback
http://127.0.0.1
Run Code Online (Sandbox Code Playgroud)
这是我的client_secret.json:
{"web": {
"client_id": "clientid",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_email": "clientemailstuff",
"client_x509_cert_url": "certurlstuff",
"client_secret": "itsasecret",
"redirect_uris": ["http://localhost:8080/","http://localhost:8080"],
"javascript_origins": ["https://testserver.net", "http://testserver.net","http://localhost:8080"]
}}
Run Code Online (Sandbox Code Playgroud)
以下是我要验证的代码:
@Override
public Credential authorize() throws IOException {
InputStream in =
DriveQuickstartImpl.class.getResourceAsStream("/client_secret.json");
GoogleClientSecrets clientSecrets =
GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
GoogleAuthorizationCodeFlow flow =
new GoogleAuthorizationCodeFlow.Builder(
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
.setDataStoreFactory(DATA_STORE_FACTORY)
.setAccessType("offline")
.build();
flow.newAuthorizationUrl().setState("xyz").setRedirectUri("http://localhost:8080/Callback");
Credential credential = new AuthorizationCodeInstalledApp(
flow, new LocalServerReceiver()).authorize("user");
if(credential!=null && credential.getRefreshToken() != null){
storeCredentials(credential);
} …Run Code Online (Sandbox Code Playgroud) java google-api google-apps google-api-java-client google-oauth
我正在研究一个带有PostgreSQL和Hibernate的Spring-MVC应用程序,其中我有几个表,行数超过10万(10万).这些表,我95%的时间只访问最新的数据,并筛选所有这些行是耗时的.很多时候查询规划器甚至没有使用索引(原因我不知道).
然后我想到每周拆分数据库表,所以我们可以先访问最新的月份数据库,然后如果用户请求,那么前一个表中的更多结果将直接添加到请求中.
执行的大多数查询都要求我们使用JOIN,因为表格是一对多映射的.
行数大于10万的模型文件之一.
型号:
@Entity
@Table(name = "groupnotehistory")
public class GroupNoteHistory {
@Id
@Column(name = "mhistoryid")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "mhistory_gen")
@SequenceGenerator(name = "mhistory_gen", sequenceName = "mhistory_seq")
private int mhistoryid;
@Column(name = "mnoteeditdate",columnDefinition = "timestamp without time zone")
private Timestamp mnoteEditDate;
@Column(name = "oldheadline", columnDefinition = "character varying")
@Type(type="jasyptHibernateEncryptor")
private String oldHeadLine;
@Column(name = "oldtext", columnDefinition = "character varying")
@Type(type="jasyptHibernateEncryptor")
private String oldText;
@Column(name = "newnotetext", columnDefinition = "character varying")
@Type(type="jasyptHibernateEncryptor")
private String newNoteText;
@Column(name = "newnoteheadline", columnDefinition …Run Code Online (Sandbox Code Playgroud) java ×9
spring ×4
spring-mvc ×3
hibernate ×2
android ×1
attachment ×1
css ×1
database ×1
google-api ×1
google-apps ×1
google-oauth ×1
html ×1
javafx ×1
jmeter ×1
jsp ×1
login ×1
mapping ×1
multipart ×1
postgresql ×1
random ×1
string ×1
superslim ×1
webkit ×1