我有一个小学课程如下:
public class classB{
public classC getObject(String getstring){
return new classC(getstring);
}
}
Run Code Online (Sandbox Code Playgroud)
该classC有一个构造器:
public class classC{
String string;
public classC(String s){
this.string = s;
}
public methodC(int i){
<using the `string` variable here>
}
}
Run Code Online (Sandbox Code Playgroud)
现在我有一个classA将使用创建的对象classB(当然是一个实例classC).
public classA{
int a = 0.5;
<Get the object that was created in classB>.methodC(a);
}
Run Code Online (Sandbox Code Playgroud)
这是需要的,因为变量是在用户的某些操作上创建并存储的classB,这将在classC方法中进一步使用.创建一个新对象会将我的变量classB设置为null,这不是预期的.
我怎样才能做到这一点?
如果Spring Bean配置发生更改,是否可以动态更新Spring Bean?
例如,假设我有一个具有boolean属性x的spring bean,并且true当应用程序启动时spring bean具有值。
因此spring会创建属性x设置为true 的bean 。
有没有一种方法可以让我将属性更改为x(在应用程序运行时),例如,将属性更新为false?
我有一个mp3文件的集合,我想连续发送到客户端,一个接一个 - 像一个基于mp3文件列表的互联网广播(假设列表是无穷无尽的).
什么是最好的方法?协议是HTTP还是RTSP无关紧要(流行的播放器无论如何都支持所有内容).
这可以用java servlets + tomcat完成,还是需要像Icecast这样的特殊服务器?
我的问题如下:假设我们有以下文件:
package p;
import javax.swing.*;
public class test extends JPanel {
test(){
super(true);
}
}
Run Code Online (Sandbox Code Playgroud)
我保存文件并编译它.现在,在IntelliJ中,我打开一个表单并尝试添加test它.它不会起作用!我点击'非调色板组件',点击我的表格,然后在打开的对话框中输入p.test我的班级名称(IntelliJ甚至在这里提供名称完成)并选中'自动创建绑定'.单击确定后,没有任何反应.但是 - 如果我把'javax.swing.JButton'作为类名,它就可以了.这太荒谬了.我不明白我做错了什么?测试是否必须实现或覆盖某个功能?我必须修改路径吗?或者我应该把我的电脑从窗户踢出来?
比如我有一个Action叫班UsersAction,我有这样一些方法:login,logout,register,等等.
我写的validate()方法如下:
@Override
public void validate() {
if ("".equals(username)) {
addFieldError("username", getText("username.required"));
}
if ("".equals(email)) {
addFieldError("email", getText("email.required"));
} else if (!Utils.isValidEmail(email)) {
addFieldError("email", getText("invalid.email.address"));
}
if ("".equals(phone)) {
addFieldError("phone", getText("phone.required"));
}
if ("".equals(password)) {
addFieldError("password", getText("password.required"));
}
}
Run Code Online (Sandbox Code Playgroud)
问题是此解决方案仅在调用注册操作时起作用,无论如何它在登录或注销时都不起作用,因为它将检查字段是否为空或电子邮件是否正确并始终会出错.好吧,对于注销的解决办法是添加@SkipValidation在其上方标注,但我不知道如何告诉它,登录只有2场username,并password和它不是必要检查email和phone太.我不想为每个动作部分写一个Action类,因为Struts 2的目的不是这个.
我需要更新具有超过60k行的表的每一行.目前我这样做 -
public void updateRank(Map<Integer,Double> map){
Iterator<Entry<Integer, Double>> it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Integer,Double> pairs = (Map.Entry<Integer,Double>)it.next();
String query = "update profile set rank = "+ pairs.getValue()+ " where profileId = "+pairs.getKey();
DBUtil.update(query);
it.remove();
}
}
Run Code Online (Sandbox Code Playgroud)
仅此方法需要大约20分钟才能完成,每行(60k)命中数据库就是我认为的原因.(虽然我使用dbcp进行连接池,最多有50个活动连接)
如果我能够使用单个数据库命中更新行,那就太好了.那可能吗 ?怎么样 ?
或者其他任何改善时间的方法?
假设我有inetOrgPersonS IN ou=people,dc=example,dc=com。例:
dn: cn=John Doe,ou=people,dc=example,dc=com
objectClass: inetOrgPerson (structural)
objectClass: person (structural)
objectClass: top (abstract)
cn: John Doe
sn: Doe
givenName: John
mail: john.doe@example.com
uid: john.doe
Run Code Online (Sandbox Code Playgroud)
另外我还有几个organization:
dn: o=foo,dc=example,dc=com
objectClass: organization (structural)
objectClass:top (abstract)
o: foo
dn: o=bar,dc=example,dc=com
objectClass: organization (structural)
objectClass:top (abstract)
o: bar
Run Code Online (Sandbox Code Playgroud)
每个organization都有一个groupOfNames:
dn: cn=users,o=foo,dc=example,dc=com
objectClass:groupOfNames (structural)
cn: users
member: cn=John Doe,ou=people,dc=example,dc=com
dn: cn=users,o=bar,dc=example,dc=com
objectClass:groupOfNames (structural)
cn: users
Run Code Online (Sandbox Code Playgroud)
如您所见,cn=John Doe,ou=people,dc=example,dc=com列为的member,cn=users,o=foo,dc=example,dc=com而不是的dn: …
我正在尝试使用Ajax中的URL连接到我的操作类.但它不会进入我的动作类,甚至它没有通过使用显示所选的值$("#selectedCountry").val().
function getstates(){
alert($("#selectedCountry").val());
$.ajax({
type : "GET",
url : "/ThirdTask/selectstate.action",
dataType : 'text',
data : "name="+$("#selectedCountry").val(),
success : function(){
$('statesdivid').html();
},
error : alert("No values found..!!")
});
}
Run Code Online (Sandbox Code Playgroud)
我的JSP代码如下:
<s:select name="selectedCountry" list="{'india','china'}" onclick="getstates();"/></div>
<div id="statesdivid">
<s:if test="%{#request.selectedstatenames != null}">
<s:select list="#request.selectedstatenames" name="selectedState">
</s:select>
</s:if>
</div>
Run Code Online (Sandbox Code Playgroud)
我的struts.xml:
<action name="selectstate.action" class="com.thirdtask.actions.SelectAction" method="selectstate">
<result name="success">selecttag.jsp</result>
</action>
Run Code Online (Sandbox Code Playgroud) 我正在尝试将设置片段添加到我的android-app中.所以,我添加了一个xml文件和这个活动:
public class SettingsActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Display the fragment as the main content.
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new SettingsFragment())
.commit();
}
public static class SettingsFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
}
}
}
Run Code Online (Sandbox Code Playgroud)
它是从主活动中的onOptionsItemSelected函数调用的:
if (id == R.id.action_settings) {
Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
return true;
}
Run Code Online (Sandbox Code Playgroud)
所以,现在,当我尝试从菜单中打开活动时,强制关闭并在控制台中收到此错误:
Force-removing child win Window{4190a9a8 u0 PopupWindow:418fc208} from container Window{418dd448 …Run Code Online (Sandbox Code Playgroud) 我想将 JEON 数组从 Struts 2 动作类传递到 JSP 页面。我正在尝试将数据集作为字符串发送。我想知道的是,如何在 JavaScript 中读取这些数据。
这是我在Action课堂上的方法:
private InputStream inputStream;
/* getter and setter*/
public String getClientMilestone() throws DAOTransientException, DBConfigException{
PaymentScheduleDao paymentScheduleDao = new PaymentScheduleDao();
List <PaymentMilestone> paymentScheduleInfo = paymentScheduleDao.getClientMilestoneInfo(projectId);
String result = "[";
for(int i=0; i<paymentScheduleInfo.size(); i++){
result += "{"+"'"+"item"+i+"' : {"+ "'"+"milestoneName"+ "'"+":"+"'"+paymentScheduleInfo.get(i).getMilestone_name()+"'"+"}"+"},";
}
result += "]";
System.out.println("result is "+result);
inputStream = new StringBufferInputStream(result);
return "success";
}
Run Code Online (Sandbox Code Playgroud)
它打印如下:
result is [{'item0' : {'milestoneName':'milestone 1'}},{'item1' : {'milestoneName':'milestone 2'}}]
Run Code Online (Sandbox Code Playgroud)
struts.xml:
<package name="ClientMilestone" namespace="/" …Run Code Online (Sandbox Code Playgroud)