所以我正在经历一些面试问题,我遇到了一个关于void和null指针的问题,声称:
没有返回类型的指针称为空指针.它可以是任何类型的数据类型.
这彻底迷惑了我!它似乎无效,根据这个问题,null可以互换使用,我不相信这是正确的.我假设void是一个返回类型,null是一个值.但我只是一个代码新手,我不确定我是对的.
请表达您对空指针是什么以及空指针是什么的看法.我不是在寻找null和void之间的区别.
我开始穿着球衣并尝试使用TDD让freemarker使用它.我想ViewProcessor
为我的模板创建一个,但是无法在类中注入servlet上下文.
这是类代码:
@Provider
public class myProcessor implements ViewProcessor<Template> {
[...]
@Context
public ServletContext myContext;
[...]
freemarkerConfiguration.setTemplateLoader(
new WebappTemplateLoader(myContext,
myContext.getInitParameter("freemarker.template.path")));
[...]
}
Run Code Online (Sandbox Code Playgroud)
这是测试代码:
public class myProcessorTest extends JerseyTest {
public static myProcessor mp;
public myProcessorTest() throws Exception{
super(new WebAppDescriptor.Builder("com.domain").build());
}
@Test
public void firstTest(){
mp = new myProcessor();
String path = new String("test.ftl");
Template template = mp.resolve(path);
assertNotNull(template);
}
}
Run Code Online (Sandbox Code Playgroud)
我使用maven与依赖关系如下:
<dependency>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-grizzly</artifactId>
<version>1.5-SNAPSHOT</version>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
当我部署到我的本地jetty服务器时,我的代码运行正常.但是,如果我想测试我的IDE代码,它没有注入servlet上下文(@Context
):myContext
是null
,当我运行测试:/
我想我错过了一些东西,但我是servlet世界的初学者.
我在hibernate.cfg.xml配置中使用了这段代码:
<?xml version="1.0"?>
<hibernate-configuration xmlns= "urn:nhibernate-configuration-2.2">
<session-factory>
<!-- SQLServer: Provider --><!--
<property name="connection.provider"> NHibernate.Connection.DriverConnectionProvider </property>-->
<!-- SQLServer: Driver -->
<property name="connection.driver_class"> NHibernate.Driver.MySqlDataDriver </property>
<!-- SQLServer: Dialeto -->
<property name="dialect"> NHibernate.Dialect.MySQLDialect </property>
<!-- SQLServer: Connection String -->
<property name="connection.connection_string"> Database=nhibernate;Data Source=localhost;User Id=root;Password=xxxx</property>
<!-- Classe que será utilizada para Proxy
(LazyLoading) -->
<property name="proxyfactory.factory_class"> NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu </property>
</session-factory>
</hibernate-configuration>
Run Code Online (Sandbox Code Playgroud)
我有一个问题是创建数据库.
NHibernate.HibernateException:无法从NHibernate.Driver.MySqlDataDriver创建驱动程序.---> System.Reflection.TargetInvocationException:调用目标抛出了异常.---> NHibernate.HibernateException:找不到程序集MySql.Data中的IDbCommand和IDbConnection实现....
我该怎么办?
我试图运行svn copy命令如下.
svn copy https://rb-svn1.in.company.com/svn/Project500/branches \
https://rb-1.in.company.com/svn/cust04/Project500/tags/V1.xx \
-m "Dummy test version V1.xx tag"
Run Code Online (Sandbox Code Playgroud)
但我收到错误信息说:
svn: Local, non-commit operations do not take a log message or revision properties
Run Code Online (Sandbox Code Playgroud)
谁能告诉我这里发生了什么?
跋蹉
在Clojure [1]中编写惯用的函数代码,如何编写一个用空格分割字符串但保持引用短语完整的函数?快速解决方案当然是使用正则表达式,但如果没有它们,这应该是可能的.快速浏览一下似乎很难!我在命令式语言中写了类似的东西,但我想看看功能性的递归方法是如何工作的.
快速检查我们的功能应该做什么:
"Hello there!" -> ["Hello", "there!"]
"'A quoted phrase'" -> ["A quoted phrase"]
"'a' 'b' c d" -> ["a", "b", "c", "d"]
"'a b' 'c d'" -> ["a b", "c d"]
"Mid'dle 'quotes do not concern me'" -> ["Mid'dle", "quotes do not concern me"]
Run Code Online (Sandbox Code Playgroud)
我不介意引号之间的间距是否变化(因此可以先使用空格分割简单).
"'lots of spacing' there" -> ["lots of spacing", "there"] ;is ok to me
Run Code Online (Sandbox Code Playgroud)
[1]这个问题可以在一般水平上回答,但我想Clojure中的一种功能方法可以轻松地转换为Haskell,ML等.
在过去的几个月/周内,我在Hibernate和JPA映射方面做了很多工作.我的数据库使用复合主键,我已经报告了大约10到15个Hibernate和5-10个EclipseLink错误.在某些应该起作用的星座中,Hibernate尤其荒谬.(我有专家和JPA书籍作者检查过的代码)
最大的问题是:
当ORM没有得到所有 JPA映射时,有什么用?
Hibernate提供了太多东西,缓存etcetc.我想知道谁在乎开发人员甚至无法创建一个有效的元数据模型......这一切都毫无意义.那么,当它没有使所有 JPA映射正确时,ORM有什么用?
我在Python2.x中使用以下内容;
import csv
f = open('test.csv', 'wb')
writer = csv.writer(f)
writer.writerow((fpath, md5sum, size)) # <str>, <str>, <int>
Run Code Online (Sandbox Code Playgroud)
这没有任何问题.但是,当我在Python3中运行它时,我得到一个TypeError.
writer.writerow((fpath, md5sum, size))
TypeError: write() argument 1 must be bytes or buffer, not str
Run Code Online (Sandbox Code Playgroud)
当然,将数据写入以非二进制模式打开的文件可以解决问题,但我喜欢在Py3中处理Unicode的方式,并希望在写入文件之前对数据进行特定编码,并在读取文件时对其进行解码.
我该如何解决这个问题?
我有一个自定义按钮布局
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<gradient android:startColor="@color/pres1"
android:endColor="@color/pres2" android:angle="270" />
<stroke android:width="5dp" android:color="@color/stro3" />
<corners android:radius="5dp" />
<padding android:left="10dp" android:top="20dp"
android:right="10dp" android:bottom="20dp" />
</shape>
</item>
<item android:state_focused="true">
<shape>
<gradient android:endColor="@color/focu1"
android:startColor="@color/focu2" android:angle="270" />
<stroke android:width="5dp" android:color="@color/stro2" />
<corners android:radius="5dp" />
<padding android:left="10dp" android:top="20dp"
android:right="10dp" android:bottom="20dp" />
</shape>
</item>
<item>
<shape>
<gradient android:endColor="@color/norm1"
android:startColor="@color/norm2" android:angle="270" />
<corners android:radius="5dp" />
<padding android:left="10dp" android:top="20dp"
android:right="10dp" android:bottom="20dp" />
</shape>
</item>
</selector>
Run Code Online (Sandbox Code Playgroud)
并为下面的布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" …
Run Code Online (Sandbox Code Playgroud) 客户已请求带有文本输入的页面,该页面采用邮政编码并返回该区域中的一系列本地商店.
我如何通过谷歌地图API或类似的东西来实现这一点,这是我第一次遇到这样的需求,并且朝着正确的方向推进将非常有帮助.
谢谢,丹
java ×2
php ×2
android ×1
c++ ×1
clojure ×1
csv ×1
encryption ×1
freemarker ×1
google-maps ×1
hibernate ×1
jersey ×1
jpa ×1
json ×1
mapping ×1
mysql ×1
nhibernate ×1
null-pointer ×1
orm ×1
passwords ×1
pointers ×1
python ×1
python-3.x ×1
recursion ×1
security ×1
servlets ×1
svn ×1
testing ×1
tortoisesvn ×1