我有一个Git存储库.我克隆了存储库,可以提交我的本地更改.当我将更改推送到服务器时,它可以工作.
一旦我创建了一个分支,我就会检查分支,提交我的工作,然后检查主分支.然后我将我的本地更改合并到主分支中.当我尝试推送到服务器时,我得到以下异常:
Welcome to Git (version 1.7.11-preview20120620)
Run 'git help git' to display the help index.
Run 'git help <command>' to display help for specific commands.
$ git push origin master:master
Counting objects: 9, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (8/8), 13.68 KiB, done.
Total 8 (delta 2), reused 1 (delta 0)
Unpacking objects: 100% (8/8), done.
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, …
Run Code Online (Sandbox Code Playgroud) 我正在使用Maven 3,我正在尝试在webapp文件夹下添加META-INF文件夹.所以我想尝试以下方法:
src
main
webapp
META-INF
context.xml
WEB-INF
Run Code Online (Sandbox Code Playgroud)
以下是我的POM文件:
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.data</groupId>
<artifactId>Java-WebApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Java-Web Application</name>
<!-- Shared version number properties-->
<properties>
<org.springframework.version>3.0.6.RELEASE</org.springframework.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>data</finalName>
</build>
<parent>
<groupId>com.data</groupId>
<artifactId>Java-Parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
</project>
Run Code Online (Sandbox Code Playgroud)
在src/main/resources下我添加了一个META-INF\context.xml.当使用mvn包打包WAR文件时,结构如下所示:
data
webapp
META-INF
WEB-INF
index.jsp
Run Code Online (Sandbox Code Playgroud)
可以看到WEB-INF下的相关文件.但是,META-INF文件夹是空白的.我的默认Maven将在WEB-INF/classes下添加资源.
我想特别希望:
data
webapp
META-INF
context.xml
WEB-INF
Run Code Online (Sandbox Code Playgroud)
这怎么可能?我尝试了其他的东西,但它仍然没有用.context.xml包含以下内容:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/data1"/>
Run Code Online (Sandbox Code Playgroud)
我尝试从src\main\resources中删除META-INF文件夹,并直接将其放在webapp\META-INF下.context.xml显示但是当部署到Tomcat时,我定义的上下文根不起作用.
我已经阅读了许多类似的问题,包括:JQuery,Spring MVC @RequestBody和JSON - 使它 与JQuery/Ajax和Spring 一起使用JSON请求
要求是服务器只接受application/json类型.我正在使用Spring MVC控制器.代码通过@ResponseBody以JSON形式发送响应.我想通过Spring MVC Controller中的@RequestBody获取信息.我正在使用JSP将JSON发送到Spring MVC Controller.我的代码和Spring MVC如下所示:
我是JSON和Javascript的新手.
JSP - index.jsp
<%@page language="java" contentType="text/html"%>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$('#myForm').on('submit', function(e) {
var frm = $("#myForm");
var dat = JSON.stringify(frm.serializeArray());
$.ajax({
type: 'POST',
url: $('#myForm').attr('action'),
data: dat,
contentType: 'application/json',
dataType: 'json',
error: function() {
alert('failure');
}
success: function(hxr) {
alert("Success: " + xhr);
}
});
);
};
</script>
</head>
<body>
<h2>Application</h2>
<form id="myForm" action="/application/save" method="POST" accept="application/json" onclick="i()">
<input type="text" …
Run Code Online (Sandbox Code Playgroud) 我使用AST树使用Antlr 3开发了一个复杂的语法.ANTLR生成Lexer和Parser.问题是当用户输入例如无效的语法时,语法期望';'.用户不输入,然后在我的Eclipse IDE中我得到以下异常:
line 1:24 mismatched input '<EOF>' expecting ';'
Run Code Online (Sandbox Code Playgroud)
如何处理此异常,因为我试图捕获此异常,但是没有捕获异常.这是一个例外吗?我似乎不明白为什么没有捕获此异常.我试图找出答案,但Antlr网站似乎已经停止了一段时间了.
我查看了以下内容:使用"$"和Java进行ANTLR异常处理并遵循该示例,但是当Lexer通过添加RuntimeException()生成代码时,我得到了无法访问的代码.
我不知道该怎么做.
当我尝试从解析器获取语法错误的数量时,它显示0.
编辑:
我找到了一个解决方案,通过查看:ANTLR不会在无效输入上抛出错误
但是,当我尝试获取Exception消息时,它为null.我是否正确设置了一切?请参阅示例语法:
grammar i;
options {
output=AST;
}
@header {
package com.data;
}
@rulecatch {
catch(RecognitionException e) {
throw e;
}
}
// by having these below it makes no difference
/**@parser::members {
@Override
public void reportError(RecognitionException e) {
throw new RuntimeException("Exception : " + " " + e.getMessage());
}
}
@lexer::members {
@Override
public void reportError(RecognitionException e) {
throw new RuntimeException("Exception …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用POP3协议收听新消息.我知道Pop3在文件夹打开时不允许新邮件出现在收件箱中.以下是我实施的代码:
import javax.mail.event.MessageCountAdapter;
import javax.mail.event.MessageCountEvent;
public class EmailListener extends MessageCountAdapter {
public EmailListener() {
}
public void messagesAdded(MessageCountEvent e) {
System.out.println("I");
}
public void messagesRemoved(MessageCountEvent e) {
System.out.println("J");
}
}
public class POPReceiver {
public POPReceiver() {
}
public void listen() throws Exception {
Properties properties = new Properties();
Session session = null;
POP3Store pop3Store = null;
String host = "NB-EX101.example.com";
String user = "user2";
properties.put(mail.pop3.host, host);
session = Session.getDefaultInstance(properties);
pop3Store = (POP3Store) session.getStore("pop3");
pop3Store.connect(user, "password");
Folder folder = pop3Store.getFolder("INBOX"); …
Run Code Online (Sandbox Code Playgroud) 我正在使用Java Spring版本1.3.1-RELEASE.在尝试执行任何操作时,LdapTemplate似乎存在问题,并且它返回NullPointerException.当我通过xml配置实例化LdapTemplate时,它可以工作.但是,当我通过Java代码实例化一个新的LdapTemplate实例并填充我放在xml配置中的属性时,它返回一个NullPointerException.
xml congfig
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
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.0.xsd">
<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
<property name="url" value="ldap://localhost:10389"/>
<property name="base" value="o=channel"/>
<property name="userDn" value="uid=admin,ou=system"/>
<property name="password" value="secret"/>
</bean>
<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
<constructor-arg ref="contextSource"/>
</bean>
<bean id="ldapService" class="com.webchannel.services.ldap.LDAPService" scope="prototype">
<!-- <property name="dao" ref="dao"></property>-->
<property name="ldapTemplate" ref="ldapTemplate"></property>
</bean>
</beans>
Run Code Online (Sandbox Code Playgroud)
当我尝试使用LdapTemplate保存条目时,它可以完美地工作.但是,当实例化一个新的LdapTemplate时,我得到一个NullPointerException:
public class LDAPService<T> {
private LdapTemplate ldapTemplate;
private LdapContextSource ldapContextSource;
public LDAPService(DAO dao) throws Exception {
ldapContextSource = new LdapContextSource();
ldapTemplate = new LdapTemplate();
ldapContextSource.setUrl(dao.findAll(LDAPDetail.class).get(0).getUrl());
ldapContextSource.setBase(dao.findAll(LDAPDetail.class).get(0).getBase());
ldapContextSource.setUserDn(dao.findAll(LDAPDetail.class).get(0).getUserDn());
ldapContextSource.setPassword(dao.findAll(LDAPDetail.class).get(0).getPassword());
ldapTemplate = new LdapTemplate(ldapContextSource); …
Run Code Online (Sandbox Code Playgroud) java ×4
antlr ×1
git ×1
git-config ×1
git-push ×1
jakarta-mail ×1
javascript ×1
jquery ×1
json ×1
jsp ×1
ldap ×1
maven ×1
pop3 ×1
smtp ×1
spring ×1
spring-mvc ×1
tomcat ×1