我连接了许多变量,我想将该字符串保存为文件路径.
是否有一种方法可以自动创建所有适当的目录,如果它们不存在而不必检查每个目录上的"if exists"
例如.
"C:\" + a + "\" + b+ "\" + d + "\" + d + ".txt"
Run Code Online (Sandbox Code Playgroud) 我有一个Java Web应用程序,它有一个用于用户交互的网站.要对用户进行身份验证,我通过web.xml配置了应用程序以使用基于FORM的身份验证.用户被转发到登录页面,到目前为止一切都很好.
现在我们正在为这个通过RESTful Web服务访问应用程序的Web应用程序开发一个桌面客户端(在C#中).我在与网站相同的Web应用程序中实现了这些服务,当然也应该对Web服务的调用者进行身份验证.但是现在我面临的问题是,无论何时我调用Web服务,服务器都会返回登录页面的HTML作为响应.
我认为能够为我的REST服务servlet使用另一个login-config(它可能会使用BASIC身份验证)会很酷.
谷歌并没有带来多少,但我无法相信我是第一个处于这种状况的人.所以我想听听你的想法和解决方案.
任何提示都表示赞赏.
我的MySQL数据库中有两个表,它们是这样创建的:
CREATE TABLE table1 (
id int auto_increment,
name varchar(10),
primary key(id)
) engine=innodb
Run Code Online (Sandbox Code Playgroud)
和
CREATE TABLE table2 (
id_fk int,
stuff varchar(30),
CONSTRAINT fk_id FOREIGN KEY(id_fk) REFERENCES table1(id) ON DELETE CASCADE
) engine=innodb
Run Code Online (Sandbox Code Playgroud)
(这些不是原始表.重点是table2有一个引用表1中主键的外键)
现在在我的代码中,我想在一个事务中向两个表添加条目.所以我设置autoCommit为假:
Connection c = null;
PreparedStatement insertTable1 = null;
PreparedStatement insertTable2 = null;
try {
// dataSource was retreived via JNDI
c = dataSource.getConnection();
c.setAutoCommit(false);
// will return the created primary key
insertTable1 = c.prepareStatement("INSERT INTO table1(name) VALUES(?)",Statement.RETURN_GENERATED_KEYS);
insertTable2 = c.prepareStatement("INSERT INTO table2 …Run Code Online (Sandbox Code Playgroud) 我最近从GWT 2.0.4更新到2.1.0.从那时起,我再也无法编译我的GWT应用程序了.当我点击GWT eclipse插件的GWT编译按钮时,我收到以下错误:
java.lang.NoClassDefFoundError: com/google/gwt/dev/Compiler
Caused by: java.lang.ClassNotFoundException: com.google.gwt.dev.Compiler
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Exception in thread "main"
Run Code Online (Sandbox Code Playgroud)
此外,我无法在Eclipse中创建新的GWT项目.在新的"新建Web应用程序项目"对话框中,可以选择使用GWT和/或Google App Engine.当选中"使用GWT"时,会出现一个错误对话框:"创建元素失败.原因:调用com.google.gwt.user.tools.WebAppCreator失败.有关详细信息,请参阅错误日志."
在日志文件(<workspace>/.metadata/.log)中,我可以看到消息:
!ENTRY org.eclipse.jdt.ui 4 10001 2010-11-02 08:34:50.085
!MESSAGE Internal Error
!STACK 1
Java Model Exception: Core Exception [code 0] Invocation of com.google.gwt.user.tools.WebAppCreator failed. See the error log for more details.
at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:50)
at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975)
at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:4777)
at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:106)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: org.eclipse.core.runtime.CoreException: Invocation of com.google.gwt.user.tools.WebAppCreator failed. …Run Code Online (Sandbox Code Playgroud) 我有一个扩展SmartGWT对话框的自定义对话框.我的问题是对话框的标题和关闭按钮不会显示在对话框的标题中,而是显示在所有其他元素下的对话框内容中.
这是一个screeshot:

粗体测试和x按钮应位于对话框的标题中.
我的代码基本上是:
public class MyDialog extends Dialog {
public MyDialog() {
super();
this.setTitle("test");
this.setShowTitle(true);
this.setShowCloseButton(true);
this.setShowMaximizeButton(false);
this.setShowMaximizeButton(false);
this.setShowStatusBar(false);
this.setShowShadow(true);
this.setWidth("500px");
this.setHeight("300px");
}
@Override
protected void onInit() {
Label lab = new Label("test");
this.addMember(lab);
}
}
Run Code Online (Sandbox Code Playgroud)
这是SmartGWT中的错误还是我遗漏了什么?如何正确放置标题?
谢谢你的帮助!