为什么spring没有绑定嵌套对象上的值?
尽管在视图中使用bean表示法在表单中进行设置,但RegistrationBean上的SecurityQuestion对象分别设置为问题和答案为null,null.
豆子:
public class SecurityQuestion {
SecurityQuestionType type;
String answer;
}
public class RegistrationBean {
@Valid
SecurityQuestion securityQuestion;
String name;
public SecurityQuestionType[] getSecurityQuestionOptions() {
return SecurityQuestionType.values();
}
}
Run Code Online (Sandbox Code Playgroud)
视图:
<form:form modelAttribute="registrationBean" method="POST">
<form:select id="securityQuestion" path="securityQuestion.question">
<c:forEach var="securityQuestionOption" items="${securityQuestionOptions}">
<form:option value="${securityQuestionOption}">${securityQuestionOption</form:option>
</c:forEach>
</form:select>
<form:input id="securityAnswer" path="securityQuestion.answer" />
<form:input id="name" path="name" />
</form:form>
Run Code Online (Sandbox Code Playgroud)
控制器:
@RequestMapping(value = URL_PATTERN, method = RequestMethod.POST)
public ModelAndView submit(@Valid final RegistrationBean registrationBean) {
// registrationBean.getSecurityQuestion().getQuestion() == null
// registrationBean.getSecurityQuestion().getAnswer() == null
}
Run Code Online (Sandbox Code Playgroud)
解
所有bean都必须拥有所有字段的getter/setter.Spring使用默认构造函数,然后使用setter从视图中改变对象.
我正在使用这种形式,它在Dreamweaver中应该出现,但是当我在网站上使用它时它再次大.该网站通过include作为动态内容(php)加载.
<form action="index.php" method="get">
<input type="hidden" name="content" value="home" />
<label>Go to
<input style height="20" width="40" type="numeric" name="page" />
</label>
<input type="submit" value="Go" />
</form>
Run Code Online (Sandbox Code Playgroud)
我感谢任何帮助!
假设我在C#程序中有三个函数doA(),doB()和doC(),我知道doA()将调用doB(),而doB()又调用doC().
由于doC()必须与数据库进行交互,因此我知道它可以很好地生成无法解决的异常,需要引起用户的注意.目前,我有一些代码可能会在doC()中的try/catch打击中抛出错误,然后在另一个try/catch中调用doB()中的doC(),同样在doA中调用doB() ()在try/catch块中.这允许我只使用throw; 将异常踢到doA(),在那里可以合理地将某些内容显示给用户.
这看起来有点像矫枉过正.我想知道是否因为我不打算在doB()或doC()中处理异常,如果我可以摆脱那里的try/catch块.
假设没有涉及最终块,处理这种情况的最佳做法是什么?
这是stackoverflow上最愚蠢的问题......
我的客户希望在他的网站的所有页面中始终可见侧栏.
有些页面有滚动,有些没有,所以他看到从一页到另一页滚动条宽度的标识和元素跳转位置......
所以...有一种方法可以"锁定"滚动条空间,所以他看不到"跳"从一页到另一页?
谢谢
我对此有一些困惑"可以将对象作为值传递给复制构造函数"编译器明确拒绝这一点,这意味着它是不可能的.你能帮我理解一下吗?
class Dummy{
Dummy(Dummy dummy){ // This is not possible
}
};
Run Code Online (Sandbox Code Playgroud)
那么为什么它会说"复制构造函数会在使用值传递时导致递归调用."
我需要对a中的元素进行排序std::vector,但我只对N排序的顶级项目感兴趣,而不是整个列表:
例如,在10个元素的列表中,只需要对前3个元素进行排序.不关心其余的......
1,2,3,6,7,4,9,8,5
这可以用std::sort吗?
编辑
我只需要找到N矢量中的顶部项目.std::partial_sort_copy真是我需要的.
我是Android编程的新手,但是我很习惯使用SQLite数据库.
我的应用程序在SD卡上打开一个SQLite3数据库并运行一个相对复杂的查询(5个连接,1个子查询,2个where子句) SQLiteDatabase.rawQuery
public Cursor queryDataBase(String sql, String[] selectionArgs){
Cursor c = myDB.rawQuery(sql, selectionArgs);
return c;
}
Run Code Online (Sandbox Code Playgroud)SQL语句由硬编码提供String.
Steps: 155 , Sorts: 0, AutoIdx: 1077我没有使用主键,因此我也没有将任何内容重命名为"_id".
rawQuery的执行速度相对较快,执行时间约为2毫秒.
那我在这里错过了什么?我的手机800 MHz,2 GB RAM,MicroSD实际上可能慢了约120倍吗?
如果用户更改了表HelloWorlds,那么我想要"他们做的动作",他们做的时间以及原始行插入的副本HelloWorldsHistory.
由于列长度,我宁愿避免单独的插入,更新和删除操作触发器.
我试过这个:
create trigger [HelloWorlds_After_IUD] on [HelloWorlds]
FOR insert, update, delete
as
if @@rowcount = 0
return
if exists (select 1 from inserted) and not exists (select 1 from deleted)
begin
insert into HelloWorldHistory (hwh_action, ..long column list..)
select 'INSERT', helloWorld.id, helloWorld.text ... and more from inserted
end
else
if exists (select 1 from inserted) and exists (select 1 from deleted)
begin
insert into HelloWorldHistory (hwh_action, ..long column list..)
select 'UPDATE', helloWorld.id, helloWorld.text ... and …Run Code Online (Sandbox Code Playgroud) 我在C#中使用naudio lib并且想要播放一个简单的文件.问题是,播放在1秒后停止.我无法弄清楚它为什么这样做.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NAudio.Wave;
namespace NAudioTest
{
class Program
{
static IWavePlayer waveout;
static WaveStream outputStream;
static string filename = null;
static void Main(string[] args)
{
waveout = new WaveOut();
filename = "C:\\1.wav";
outputStream = CreateInputStream(filename);
try
{
waveout.Init(outputStream);
}
catch (Exception ex)
{
Console.WriteLine("Error while loading output");
Console.WriteLine("Details: " + ex.Message);
Console.ReadLine();
return;
}
Console.WriteLine("Press [Enter] to start playback");
Console.ReadLine();
waveout.Play(); //this stops after 1 sec. should it play until i …Run Code Online (Sandbox Code Playgroud) 我需要将select查询输出保存到临时表中.然后我需要对这个临时表进行另一个选择查询.有谁知道怎么做?
我需要在SQL Server上做这个.