我正在构建一个应用程序,并想知道将未使用的对象设置为nil是生产级编码中的常见做法.
据我所知,这只是垃圾收集器的一个暗示,并不会总是丢弃一个对象.
您好,我一直在浏览互联网文章论坛来解决我的问题,但到目前为止还没有结果。我正在尝试在 localhost 上为我的 FuelPHP 开发设置 Apache 虚拟主机,但我不断收到错误 403 消息。这是我当前的设置。
#/etc/apache2/sites-enabled/000-default
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@example.com
DocumentRoot "/home/supercomputer/Desktop/PHP/fuelProject/public"
ServerName localhost.home
<Directory "/home/supercomputer/Desktop/PHP/fuelProject/public" >
Options Indexes FollowSymLinks MultiViews Includes ExecCGI
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
我已将我的文档根目录指向 FuelProject 中的公共文件夹。另外,为了确保 Apache 能够访问服务器文件,我递归地设置了所有文件的读取、写入和执行权限,以保证 100% 的安全。关于还有什么可能出问题的任何线索吗?
PS:我正在运行 ubuntu raring (13.04)
PSS:我正在尝试访问 localhost.home 和 localhost.home/index.php。重新启动服务器时我还收到以下警告
* Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[Fri May 03 15:46:58 …Run Code Online (Sandbox Code Playgroud) 关于如何编程,我有点困惑.我有一个类扩展JFrame与两个文本字段.我希望能够从JFrame获得输入.不知何故只是等待我的mainMaybe课程的输入...任何想法?
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JTextField;
public class mainMaybe extends JFrame{
JTextField login;
JTextField pass;
public mainMaybe() throws InterruptedException{
login = new JTextField();
pass = new JTextField();
pass.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
System.out.println("DO SOMETHING");
}
});
add(login,BorderLayout.NORTH);
add(pass,BorderLayout.SOUTH);
pack();
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void returnEmail(){
//SOME HOW WAIT FOR THE ACTION LISTENER?
}
public static void main(String[] args) throws InterruptedException {
new mainMaybe().returnEmail();
//CONTROL SHOULD STAY WITH mainMaybe until an email is returned …Run Code Online (Sandbox Code Playgroud) 好吧我正在使用JavaMail库,我正在尝试获取某些消息号.我想有效地做到这一点,而不是必须循环两次...无论如何我的问题是:我怎么能创建一个从索引开始并在索引x结束x - 11而不循环的数组?
我是rails的新手,我在使用rails的Pragmatic Agile Web开发中跟踪Depot应用程序,我遇到了一个奇怪的问题.
在我的产品模型中,我创建了一个验证器,用于确认图像url字段中要求的图像实际上是作为资产存在的.这是我的产品型号代码.
class Product < ActiveRecord::Base
attr_accessible :description, :image_url, :price, :title
validates :description, :price, :title, :presence => true
validate :image_url_exists, on: :create
def image_url_exists
if Rails.application.assets.find_asset(image_url) == nil
errors.add(:image_url, 'is not valid. The image does not exist.')
end
end
end
Run Code Online (Sandbox Code Playgroud)
现在的问题是我运行我的单元测试.这是它的内容:
require 'test_helper'
class ProductTest < ActiveSupport::TestCase
test "the products attributes should not be empty" do
p = Product.new
assert p.invalid?
end
end
Run Code Online (Sandbox Code Playgroud)
但这样做会在我的代码中触发一堆错误.没有自定义验证器,一切似乎都运行得很好.以下是我目前遇到的错误.
test_the_products_attributes_should_not_be_empty(ProductTest):
TypeError: can't convert nil into String
/var/lib/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:156:in `initialize'
/var/lib/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:156:in `new'
/var/lib/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:156:in `find_asset'
/var/lib/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in …Run Code Online (Sandbox Code Playgroud)