在ASP.NET MVC中,我有一个看起来像这样的控制器:
public class MyController{
public ActionResult Index(){
return View(new MyModel());
}
[HttpPost]
public ActionResult Index(MyModel model){
//do something
return View("RegistrationConfirmation", new ConfirmModel());
}
[HttpPost]
public ActionResult RegistrationConfirmation(ConfirmModel model){
//do something else
return View();
}
}
Run Code Online (Sandbox Code Playgroud)
我希望用户的工作流程如下
GET页面索引.返回视图Index.网址:~/MyPOST索引页面中的数据 - 返回视图RegistrationConfirmation并将用户发送到右页~/My/RegistrationConfirmation.POST在RegistrationConfirmation页面上的另一个数据,以便RegistrationConfirmation调用它们来处理它们.现在RegistrationConfirmation从不调用action方法,因为在RegistrationConfirmation通过Index操作方法返回视图后,URL保持不变,~/My因此第二个帖子由Index(MyModel)action方法而不是RegistrationConfirmation(ConfirmModel)action方法处理.
如何更改URL以及发送View以便在POST后面调用与视图对应的控制器操作?或者还有其他方法可以确保调用相应的控制器吗?
注意:在发布这个问题之前,我确实已经阅读了20多个关于主题的问题.我认为对他们中任何一个人的完美答案都不会给我解决方案.请在投票前正确阅读以复制为准.
我有以下包含单个记录的.ini文件(名为metrics.ini),但将来可能会添加更多记录:
$DatabaseConnection_STR=MYSERVER\MYINSTANCE
Run Code Online (Sandbox Code Playgroud)
我需要将此文件解析为PowerShell变量.我可以使用以下内容解析字符串,但是我无法创建新的$ DatabaseConnection_STR变量(基于从.ini文件解析的内容).我不想在我的脚本中硬编码$ DatabaseConnection_STR - 我宁愿让脚本弄清楚它以便将来可以处理其他变量.
# This code assumes that no blank lines are in the file--a blank line will cause an early termination of the read loop
########################################
#
# Confirm that the file exists on disk
#
########################################
$IniFile_NME="C:\temp\metrics.ini"
dir $IniFile_NME
########################################
#
# Parse the file
#
########################################
$InputFile = [System.IO.File]::OpenText("$IniFile_NME")
while($InputRecord = $InputFile.ReadLine())
{
# Display the current record
write-host "`$InputRecord=$InputRecord"
write-host ""
# Determine the position of the equal sign (=)
$Pos = …Run Code Online (Sandbox Code Playgroud) 在我正在构建的rails 2应用程序中,我需要更新具有特定属性的记录集合.我有一个命名范围来查找集合,但我必须迭代每个记录以更新属性.我不必进行一次查询来更新数千条记录,而是要进行数千次查询.
到目前为止我发现的是类似的东西 Model.find_by_sql("UPDATE products ...)
这感觉真的很年轻,但我用Google搜索并环顾四周并没有找到答案.
为清楚起见,我所拥有的是:
ps = Product.last_day_of_freshness
ps.each { |p| p.update_attributes(:stale => true) }
Run Code Online (Sandbox Code Playgroud)
我想要的是:
Product.last_day_of_freshness.update_attributes(:stale => true)
Run Code Online (Sandbox Code Playgroud) 我有一个继承自Button的MyButton类.在这个课程中,我已经放置了其他几个控件(Labels,Progessbar).这样做的问题是Button上的控件使得无法触发Button.Click或Button.MouseHover事件.如何才能实现按钮上的控件仅显示但是"事件透明":标签和progessbar上的单击/悬停与我直接单击/悬停在按钮上(包括发件人和所有内容)相同.像"继承父母的事件"之类的东西.
class MyButton : Button
{
Label foo = new Label();
ProgressBar bar = new ProgessBar();
}
Run Code Online (Sandbox Code Playgroud) 我试图了解我在 Java 中绕过多态的方式。我创建了一个父类,它有太多的通用方法,所有的孩子都会以相同的方式使用。
每个子类的子类都共享静态信息,这些变量或信息将用于仅在父类中声明的方法中。
希望从父方法访问静态变量的问题似乎不太可能,
它是声明每个实例的公共信息的解决方案,但由于将有 1000 个实例,因此浪费了内存。
我的意思的简单阐述是以下代码:
class testParent {
static int k;
public void print()
{
System.out.println(k);
}
}
class testChild2 extends testParent
{
static
{
testChild2.k =2;
}
}
public class testChild1 extends testParent{
static
{
testChild1.k = 1;
}
public static void main(String[] args)
{
new testChild1().print();
new testChild2().print();
new testChild1().print();
}
}
Run Code Online (Sandbox Code Playgroud)
我期望的输出是
1
2
1。
但发生的情况是:
1
2
2
人们可能会认为在每个子类的初始化时设置了这个子类的静态变量,然后所有引用这个子类的方法都可以访问相应的 'k ' 价值。
但实际发生的情况是,所有子类都在同一个静态变量中进行编辑,该变量与所有子类共享,因此破坏了我为每个子类及其实例使用静态变量并在父类中使用通用方法访问这些变量的全部意义。
知道怎么做吗?
这就是我向listview添加数组的方法:
ListView my_listview = (ListView)findViewById(R.id.listView1);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, my_array);
my_listview.setAdapter(adapter);
Run Code Online (Sandbox Code Playgroud)
my_array是一个文件的uri.
它运作良好.但是接下来我想要对一个新阵列进行排列,那么我不想用新的阵列替换,而是将新的阵列添加到现有的阵列中.我怎么能做到这一点?
我试图将一个TabLayoutPanel置于一个uibinder中,并且没有任何运气.正如你在下面看到的,我已经尝试了我能想到的每一个CSS技巧.有人可以帮忙吗?
<ui:style>
.gwt-TabLayoutPanel {
vertical-align: middle;
text-align: center;
margin-left: auto;
margin-right: auto;
border-top: 1px solid #666;
border-left: 1px solid #999;
border-right: 1px solid #666;
}
</ui:style>
<g:VerticalPanel ui:field="userInterfacePanel" width="100%">
<mapmaker:MapBox ui:field="mapBox"/>
<g:TabLayoutPanel barHeight="20" ui:field="interfaceTabs" height="300px" width="80%" >
<g:tab>
<g:header>Lines</g:header>
<g:Label>Select Line Data Here</g:Label>
</g:tab>
<g:tab>
<g:header>Features</g:header>
<g:Label>Select Features Data Here</g:Label>
</g:tab>
<g:tab>
<g:header>Help</g:header>
<g:Label>Help goes here</g:Label>
</g:tab>
</g:TabLayoutPanel>
<g:HorizontalPanel>
<g:Button>Generate KML</g:Button>
<g:Button>Generate Shapefile</g:Button>
</g:HorizontalPanel>
</g:VerticalPanel>
Run Code Online (Sandbox Code Playgroud)
我正在使用VS2008调试C++应用程序,并且使用一些长选择查询,我无法在调试器中看到全文.它只显示查询的一部分.
有没有办法看全文?
提前致谢.

编辑:字符串中可用的真实查询是:
select c.cd_seq, m.diag_code, m.diag_descr, 'S' as source
from custom_booking_data c
left outer join meddiagnosis m
on c.cd_number_value = convert( decimal( 28, 8 ), m.diag_urn )
where c.custom_data_urn = 4 and c.cd_field = 433
union
select c.cd_seq, m.diag_code, m.diag_descr, 'H' as source
from custom_booking_data c
left outer join ordiagnosis m
on c.cd_number_value = convert( decimal( 28, 8 ), m.diag_urn )
where c.custom_data_urn = 4 and c.cd_field = 594
Run Code Online (Sandbox Code Playgroud)
如果你问我,不会那么久.
我正在使用以下XSLT将XML转换为XML.我需要验证所需元素的源XML.如果所需节点缺少兄弟节点的值,则创建一个新节点.这是XSLT
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<Data Schema="XML A">
<xsl:apply-templates/>
</Data>
</xsl:template>
<xsl:template match="Attribute[not(Type=following::Type)]">
<Attributes type="{Type}">
<xsl:apply-templates
select="../Attribute[Type=current()/Type]" mode="out"/>
</Attributes>
</xsl:template>
<xsl:template match="Attribute" mode="out">
<Attr id="{id}" name="{Name}" value="{Value}"/>
</xsl:template>
<xsl:template match="Attribute"/>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
这是XML
<?xml version="1.0" encoding="windows-1252"?>
<XML>
<Attributes>
<Attribute>
<id>331</id>
<Name>Enviornment</Name>
<Type>common</Type>
<Value>Development</Value>
</Attribute>
<Attribute>
<id>79</id>
<Name>Retail</Name>
<Type>common</Type>
<Value></Value>
</Attribute>
<Attribute>
<id>402</id>
<Name>Gender</Name>
<Type>category</Type>
<Value>Men</Value>
</Attribute>
</Attributes>
</XML>
Run Code Online (Sandbox Code Playgroud)
如果缺少必需的元素,那么它应该创建以下XML.我有多个必需的元素.
<?xml version="1.0" encoding="utf-8"?>
<Data Schema="XML A">
<Attributes type="common">
<Attr id="331" name="Enviornment" value="Development" />
<Attr id="79" name="Retail" value="" />
</Attributes>
<Attributes type="category"> …Run Code Online (Sandbox Code Playgroud) 有没有办法在两次部署的战争之间共享应用程序上下文?一场战争需要接通另一场战争的服务,我不知道从哪里开始.
c# ×2
java ×2
android ×1
asp.net ×1
asp.net-mvc ×1
containers ×1
debugging ×1
events ×1
gwt ×1
inheritance ×1
polymorphism ×1
powershell ×1
redirect ×1
required ×1
spring ×1
static ×1
string ×1
tomcat ×1
uibinder ×1
url ×1
validation ×1
war ×1
xml ×1
xslt ×1