亲爱的,我是PHP世界的一个初学者(PHP 5.3.5)我的网络服务器是在win xp上的IIS fastCGI我试图将值从HTML表单传递给php但数据未通过
<html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
<html>
<body>
Welcome <?php echo $_POST["fname"]; ?>!<br />
You are <?php echo $_POST["age"]; ?> years old.
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
按下提交后输出就像这样
欢迎!
你今年岁.
但它应该是这样的
欢迎约翰!
你今年28岁.
你能帮我解决这个问题吗?
在使用Ninject.MVC 2.2.0.3(合并之后)的MVC3应用程序中,而不是将repostories直接注入控制器,我试图创建一个包含businesslogic的服务层并在那里注入repostories.我将ninject-DependencyResolver作为动态对象传递给服务层(因为我不想在那里引用mvc或ninject).然后我在其上调用GetService来获取我在NinjectHttpApplicationModule中指定的绑定和生命周期的存储库.编辑:简而言之,它失败了.
在这种情况下,如何将IoC容器传递给服务层?(不同的方法也非常受欢迎.)
编辑:这是一个例子来说明我如何理解答案和评论.
我应该避免服务定位器(反)模式,而是使用依赖注入.所以我想说我想在Northwind中为产品和类别创建一个管理站点.我根据表定义创建模型,存储库,服务,控制器和视图.此时服务直接调用存储库,没有逻辑.我有功能支柱,视图显示原始数据.这些绑定是为NinjectMVC3配置的:
private static void RegisterServices(IKernel kernel)
{
kernel.Bind<ICategoryRepository>().To<CategoryRepository>();
kernel.Bind<IProductRepository>().To<ProductRepository>();
}
Run Code Online (Sandbox Code Playgroud)
存储库实例是由ninject通过ProductController中的两层构造函数注入创建的:
private readonly ProductsService _productsService;
public ProductController(ProductsService productsService)
{
// Trimmed for this post: nullchecks with throw ArgumentNullException
_productsService = productsService;
}
Run Code Online (Sandbox Code Playgroud)
和产品服务:
protected readonly IProductRepository _productRepository;
public ProductsService(IProductRepository productRepository)
{
_productRepository = productRepository;
}
Run Code Online (Sandbox Code Playgroud)
我现在没有必要解耦服务,但已准备好模拟数据库.
要在Product/Edit中显示类别下拉列表,我创建一个ViewModel,除了Product之外还包含类别:
public class ProductViewModel
{
public Product Product { get; set; }
public IEnumerable<Category> Categories { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
ProductsService现在需要CategoriesRepository来创建它.
private readonly ICategoryRepository _categoryRepository; …Run Code Online (Sandbox Code Playgroud) asp.net-mvc ninject inversion-of-control ninject-2 asp.net-mvc-3
我试图让我的程序在执行某些操作时不断更新方法中的进度条值.然而,直到最后才会发生这种情况,并且UI会冻结.
在查看与我的问题类似的问题后,我尝试实现已接受的解决方案(使用线程)但是我无法使其正常工作.就像他们不在那里一样.
我的程序包含几个类,它们Main是由Netbeans在JFrame 设计模式下自动创建的类,所以有一些东西,比如static void main和public Main那些不确定它的一些内容.在我将把这些方法的片段与我的线程实现一起.
public class Main extends javax.swing.JFrame implements ActionListener, Runnable{
// I added implements ActLis, Runn.....
...
static Main _this; // I included this variable
...
public static void main(String args[]) {
Main m = new Main(); // Added by me
new Thread(m).start(); // Added by me
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Main().setVisible(true);
}
});
}
...
public Main() {
initComponents();
_this = this; // …Run Code Online (Sandbox Code Playgroud) 我在CakePHP中有一个查询,它有一个存储的"datetime"字段DropIn.drop_in_time.我只想"找到"条目,DropIn.drop_in_time is > NOW()但我很难做到这一点.
条件DropIn.drop_in_time >' => 'NOW()未在下面的查询中得到正确的结果.有没有更好的方法呢?
$requests = $this->DropIn->find('all', array(
'conditions' => array('DropIn.drop_in_time >' => 'NOW()', 'or' => array(array('DropIn.user_id' => $this->Auth->user('id')), array('DropIn.id' => $drop_in_ids))),
'order'=>array('DropIn.created'=>'DESC')));
Run Code Online (Sandbox Code Playgroud) 是否有更多的自动方式在Scala中打开资源并将方法应用于此方法(直接从java转换),使用__CODE__但也包括finally等.
var is: FileInputStream = null
try {
is = new FileInputStream(in)
func(is)
} catch {
case e: IOException =>
println("Error: could not open file.")
println(" -> " + e)
exit(1)
} finally {
if(is) is.close()
}
Run Code Online (Sandbox Code Playgroud) 我正在使用Model-First模式中的Entity Frameworks 4.0(CTP5)构建ORM.我的一些实体具有复杂(对象树)属性,不需要是ORM实体 - 它们只对使用此数据库的后端服务器系统感兴趣,而不是对使用此数据库的客户端感兴趣.
我可以将属性的对象树序列化为字符串并将其作为字符串存储在DB中,但SQL Server XML数据类型确实很吸引人.能够以智能方式查询XML数据内容将是非常好的.
但是,我没有看到任何方法在Visual Studio实体建模器中指定我想要XML数据类型.
是完成此操作以在模型中指定字符串字段,发出DDL,然后修改DDL以将字符串字段更改为XML字段的唯一方法吗?这似乎非常脆弱,只写一次,永远不会改变.有没有更好的办法?
在我的注册过程中,用户注册,他们会通过电子邮件发送验证链接,如果他们点击它,那么他们的帐户才会被验证.但这种验证方法对于僵尸程序来说不是太容易了吗?
我认为电子邮件可以由机器人创建,但是如果验证只是点击链接,它也可以由机器人自动完成.我不确定,因为我没有这样做而且不关心测试它只是为了知道,但我的问题是这个验证方法是不是有缺陷?
我正在考虑将验证码作为文本发送给用户,他们必须将其手动复制/粘贴到表单中,并且表单受验证码保护.这是一个更好的主意吗?有任何缺陷吗?
为什么.NET中的值为null?这是否优于保证所有内容都具有值并且没有任何调用为空?
任何人都知道这些方法的名称是什么?
无论哪种方式,我对此都知之甚少,但是在简单性方面,即在消除空检查方面,并且能够编写更加简化的算法而不必分支出来检查.
在性能,简洁性,平行性,面向未来等方面,每种风格的优缺点是什么?
我希望有
我不知道如何将所有这些结合在一起.
<form action="upgage.php">
revision <input type="text" name="revision" value="" /><br />
<input type="submit" value="update code base" />
<input type="submit" value="get current revision" />
</form>
Run Code Online (Sandbox Code Playgroud)
我想只使用javascript而不是jQuery
那么简单.我想使用列表推导生成列表的所有子列表.
即:getSublist [1,2,3]是[[1],[2],[3],[1,2],[1,3],[2,3],[1,2,3]]
谢谢
.net ×2
php ×2
ajax ×1
asp.net-mvc ×1
c# ×1
cakephp ×1
clr ×1
datetime ×1
haskell ×1
java ×1
javascript ×1
ninject ×1
ninject-2 ×1
performance ×1
progress-bar ×1
registration ×1
scala ×1
security ×1
swing ×1
swingworker ×1
type-systems ×1
xml ×1