我有一个变量:
private ArrayList<LabelValueBean> circleNameIdList;
Run Code Online (Sandbox Code Playgroud)
在我的Action班级中,它的价值被填充。
I want to display the label in my drop-down in JSP and when one label is selected, the corresponding value to that particular label in circleNameIdListto be passed to the server. 例如:如果 label:NewYork被选中,那么它是对应的id = 5,被发送到服务器。
我怎样才能做到这一点?
到目前为止,我在 JSP 中是这样做的:
<s:select list="#session.circleNameIdList" label="Select Circle:" name="circleNameIdList" id="circleNameIdList"></s:select>
Run Code Online (Sandbox Code Playgroud)
但是,显示不正确。
我想在jsp页面中格式化一些数字.
首先,我在我的porperties中定义了一些资源
format.number.with2Decimal={0,number,#0.00}
......
问题1:
我想知道'#'和'0'是什么意思?
0.00,#0.00,##.00,### 0.00
谁能告诉我它们之间的区别?谢谢!
问题2:
如果我在我的动作BigDecimal number1中定义一个BigDecimal类型;
然后我的页面应该使用一种格式来显示这个值,
1.if number1=null then show -NIL-
2.if number1=0 then show -NIL-
3.if number1>0 then show 1.00,3434.98 .....
请忽略数字<0
问题3:
将number1更改为String,
1.if number1=null or empty or blank then show -NIL-
2.if number1=Hello then show Hello ....
你能帮我个忙吗?
我正在尝试使用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) 在版本4.3.0.Final的hibernate文档中,给出了以下代码片段来创建SessionFactory:
package org.hibernate.tutorial.util;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class HibernateUtil {
private static final SessionFactory sessionFactory = buildSessionFactory();
private static SessionFactory buildSessionFactory() {
try {
// Create the SessionFactory from hibernate.cfg.xml
return new Configuration().configure().buildSessionFactory();
}
catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
Run Code Online (Sandbox Code Playgroud)
这似乎已经过时,因为该方法buildSessionFactory()已被弃用.创建的正确方法是 …
我有一个仅包含 int 值的接口(因此本质上,它与枚举非常相似)。
我想使用以下代码来迭代接口值:
for (Field x : MyInterface.class.getDeclaredFields())
{
int y = x.getInt(x);
// do something with 'y'...
}
Run Code Online (Sandbox Code Playgroud)
在我看来, getInt 方法可以是静态的,或者不需要任何参数。
那么为什么这个方法需要“this”和附加参数呢?
是否存在任何可能的情况让它们有所不同?
任何人都可以帮我找出以下异常的解决方案,我想我只是不太了解事务传播机制,这阻碍了我理解下面显示的异常消息的真实含义,所以请帮助我理解整个事情,非常感谢你!
java.lang.IllegalStateException: Existing transaction detected in JobRepository. Please fix this and try again (e.g. remove @Transactional annotations from client).
at org.springframework.batch.core.repository.support.AbstractJobRepositoryFactoryBean$1.invoke(AbstractJobRepositoryFactoryBean.java:164)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at com.sun.proxy.$Proxy15.createJobExecution(Unknown Source)
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:111)
at TestJob.testExcelParserTasklet(TestJob.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.MethodInvocationHelper$1.runTestMethod(MethodInvocationHelper.java:169)
at org.springframework.test.context.testng.AbstractTestNGSpringContextTests.run(AbstractTestNGSpringContextTests.java:158)
Run Code Online (Sandbox Code Playgroud)
以下是导致上述异常的代码:
public class TestJob extends BaseTest {
@Test
public void testExcelParserTasklet() throws JobParametersInvalidException, JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException, NoSuchJobException {
Job job = jobRegistry.getJob("parseExcelJob");
jobLauncher.run(job, new JobParameters());
}
}
Run Code Online (Sandbox Code Playgroud)
这是BaseTest:
@ContextConfiguration("classpath:application-context.xml")
public abstract class BaseTest …Run Code Online (Sandbox Code Playgroud) 我是 Struts 2 的新手,我一直在关注 Struts 2(Koushik) 的视频教程。我已经创建了 Struts.xml、动作类和 JSP,与教程中创建的一样。但它给出了以下例外。
例外:
Jan 13, 2014 9:30:48 PM org.apache.struts2.dispatcher.Dispatcher warn
WARNING: Could not find action or result: /Struts2Starter/getTutorial.action
There is no Action mapped for namespace [/] and action name [getTutorial] associated with context path [/Struts2Starter]. - [unknown location]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37)
at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:552)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at …Run Code Online (Sandbox Code Playgroud) 我正在尝试从运行 Struts2、Hibernate 和 Spring 的 Web 服务器下载文件,但我总是遇到此异常。
java.lang.IllegalArgumentException: Can not find a java.io.InputStream with the name [inputName] in the invocation stack. Check the <param name="inputName"> tag specified for this action.
org.apache.struts2.dispatcher.StreamResult.doExecute(StreamResult.java:237)
org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:371)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:275)
org.apache.struts2.interceptor.DeprecationInterceptor.intercept(DeprecationInterceptor.java:41)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:249)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:249)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:139)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.riteshsangwan.ossoc.core.interceptors.AuthenticationInterceptor.intercept(AuthenticationInterceptor.java:34)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) …Run Code Online (Sandbox Code Playgroud) 我在Java中有以下代码:
HttpURLConnection con = (HttpURLConnection)new URL(url).openConnection();
con.connect();
InputStream stream = con.getInputStream();
BufferedReader file = new BufferedReader(new InputStreamReader(stream));
Run Code Online (Sandbox Code Playgroud)
此时,我在搜索内容时从头到尾读取文件:
while (true)
{
String line = file.readLine();
if (line == null)
break;
// Search for something...
}
Run Code Online (Sandbox Code Playgroud)
现在,我想在文件中搜索其他内容,而无需打开另一个URL连接。
出于与该问题无关的原因,我希望避免在“单个文件扫描”中搜索这两种内容。
我可以倒带文件reset吗?
如果是,我应该将其应用于InputStream对象,BufferedReader对象还是同时应用于两者?
如果不是,那么我应该简单地关闭文件并重新打开它吗?
如果是,我应该将其应用于InputStream对象,BufferedReader对象还是同时应用于两者?
如果不是,我又该如何再次清除文件,而无需再次读取URL连接?
java ×10
struts2 ×5
jsp ×4
hibernate ×2
ajax ×1
android ×1
bigdecimal ×1
format ×1
inputstream ×1
jakarta-ee ×1
jquery ×1
ognl ×1
preferences ×1
settings ×1
spring ×1
spring-batch ×1
transactions ×1