我学习jsp.我在jsp中的isThreadSafe属性中有很大的困惑.默认情况下,Jsp不是线程安全的isThreadSafe= true
如果我们设置isThreadSafe=false意味着JSP引擎确保一次只有一个线程正在执行您的JSP.
我有真或假的混淆.isThreadSafe = false意味着只有muliple线程可以通过isThreadSafe访问jsp
isThreadSafe是什么意思?
The isThreadSafe option marks a page as being thread-safe.
By default, all JSPs are considered thread-safe. If you set the isThreadSafe option to false, the JSP engine makes sure that only one thread at a time is executing your JSP.
The following page directive sets the isThreadSafe option to false:
<%@ page isThreadSafe="false" %>
Run Code Online (Sandbox Code Playgroud)
线程安全意味着多个线程无法一次访问jsp页面是否正确?
我正在使用 Twitter Stream API 来获取用户的推文。我有用户 ID 列表 我如何从 TwitterStream API 获取推文列表。我分析了以下示例
public class TwitterStreamAPI {
public static void main(String[] args) {
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true);
cb.setOAuthConsumerKey("xxxx");
cb.setOAuthConsumerSecret("xxx");
cb.setOAuthAccessToken("xxx");
cb.setOAuthAccessTokenSecret("xxx");
TwitterStream twitterStream = new TwitterStreamFactory(cb.build()).getInstance();
UserStreamListener listener = new UserStreamListener() {
@Override
public void onStatus(Status status) {
System.out.println("onStatus @" + status.getUser().getScreenName() + " - " + status.getText());
}
@Override
public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {
//System.out.println("Got a status deletion notice id:" + statusDeletionNotice.getStatusId());
}
@Override
public void onDeletionNotice(long directMessageId, long …Run Code Online (Sandbox Code Playgroud) <action name="saveGetStarted" class="com.sample.action.GetStartedAction" method="save">
<interceptor-ref name="defaultStack"/>
<result name="success" type="redirect-action">
<param name="actionName">preQualification</param>
<param name="customerId">${customerId}</param>
</result>
<result name="input">/jsp/getStarted.jsp</result>
<result name="error">/jsp/getStarted.jsp</result>
</action>
<action name="preQualification" class="com.sample.action.PreQualificationAction">
<result name="success">/jsp/preQualification.jsp</result>
<result name="input" >/jsp/preQualification.jsp</result>
</action>
Run Code Online (Sandbox Code Playgroud)
随着struts2-core-2.0.12.jar它工作正常,但在更新后struts2-core-2.1.6.jar,我得到以下错误:
Caused by: There is no result type defined for type 'redirect-action' mapped with name 'success'. Did you mean 'redirectAction'? - result - file:/D:/eclipse-indigo/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/Fundation/WEB-INF/classes/struts.xml:19:54
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildResults(XmlConfigurationProvider.java:613)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:364)
... 26 more
Run Code Online (Sandbox Code Playgroud)
是什么导致错误?
我有json数组作为字符串
[
{
"id":"1",
"lat": "23.053",
"long": "72.629",
"location": "ABC",
"address": "DEF",
"city": "Ahmedabad",
"state": "Gujrat",
"phonenumber": "1234567"
},
{
"id":"2",
"lat": "23.053",
"long": "72.629",
"location": "ABC",
"address": "DEF",
"city": "Ahmedabad",
"state": "Gujrat",
"phonenumber": "1234567"
},
{
"id":"3",
"lat": "23.053",
"long": "72.629",
"location": "ABC",
"address": "DEF",
"city": "Ahmedabad",
"state": "Gujrat",
"phonenumber": "1234567"
},
{
"id":"4",
"lat": "23.053",
"long": "72.629",
"location": "ABC",
"address": "DEF",
"city": "Ahmedabad",
"state": "Gujrat",
"phonenumber": "1234567"
},
{
"id":"5",
"lat": "23.053",
"long": "72.629",
"location": "ABC",
"address": "DEF", …Run Code Online (Sandbox Code Playgroud) 在运行Intellij对我编写的一些javascript的检查时,它会报告
函数'createPages'在第35行有不一致的返回点
但我不确定这意味着什么,或者如何解决这个问题.
该函数如下所示:
function createPages(noOfCounts) {
var default_page = 1, default_count = 15;
if (noOfCounts != "" && noOfCounts != null) {
if (noOfCounts > default_count) {
try {
var tempVal = parseInt(noOfCounts / default_count);
jQuery("#page").val(tempVal);
return true;
}
catch (e) {
alert('Error . ' + e);
}
} else {
alert("It should not be less than the 15 and should be a number");
return false;
}
}
else {
jQuery("#page").val(default_page);
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
正如这样被称为:
var valid = …Run Code Online (Sandbox Code Playgroud) 在Intellij的想法12.1.4.Spring上下文配置显示多个文件位置的错误,如Top level element is not completed
@ContextConfiguration(locations = {"classpath:sampleWebService-test.xml"})
我怎么解决这个问题?
我使用验证插件使用jQuery表单验证.我已经验证了密码,最少7个字符和一个大写和oe号码.当我遇到密码有效时,需要在文本字段附近显示正确的图像.否则图像错误.
jQuery.validator.addMethod('mypassword', function(value, element) {
return this.optional(element) || (value.match(/[A-Z]/) && value.match(/[0-9]/));
},
'Password must contain at least one capital and one number.');
jQuery("#loanRequestDetailsForm").validate({
ignore: "",
rules : {
password: {
required: true,
minlength: 7,
mypassword :true
},
confirmpassword: {
required: true,
minlength: 7,
equalTo: "#password"
}
},
messages : {
password : {
required:"Please provide a password",
minlength:"Your password must be at least 7 characters long"
},
confirmpassword : {
required:"Please provide a password",
minlength:"Your password must be at least …Run Code Online (Sandbox Code Playgroud) 我想将日期转换为时间戳
Thu Jul 04 13:32:51 IST 2013 时间戳值
java.sql.Timestamp timeStampDate = new
Timestamp(user.getCreatedTime().getTime());
System.out.println("Today is " +timeStampDate);
Run Code Online (Sandbox Code Playgroud)
但它给出了结果,因为2013-07-04 13:32:51.0我只需要像1372924971000这样的长值.
我正在尝试使用http://mbraak.github.io/jqTree/#tutorial中的jqTree
我的页面是
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Json Parser </TITLE>
<link rel="stylesheet" href="css/jqtree.css">
<script src="js/jquery-2.0.3.min.js"></script>
<script src="js/tree.jquery.js"></script>
<script type="text/javascript">
$(function() {
var data = [{"tweetText":"RT @dna: IPL spot-fixing: Jagmohan Dalmiya still clueless about N Srinivasan's return http://t.co/PwDniu8sJg","urlsMentioned":[],"usersMentioned":[{"userId":17710740,"screenName":"dna","userName":"dna"}],"source":"<a href=\"http://twitter.com/download/android\" rel=\"nofollow\">Twitter for Android</a>","tweetId":362907208733827100,"reTweetCount":12,"reTweeted":true,"createdDate":"Thu Aug 01 12:06:35 UTC 2013","user":{"location":"","userId":24525170,"screenName":"varuntripathi1","userName":"varun","profileDescription":"","language":"en"},"reTweetedStatus":{"tweetText":"IPL spot-fixing: Jagmohan Dalmiya still clueless about N Srinivasan's return http://t.co/PwDniu8sJg","urlsMentioned":["http://dnai.in/bAoD"],"usersMentioned":[],"source":"<a href=\"http://twitter.com/tweetbutton\" rel=\"nofollow\">Tweet Button</a>","tweetId":362606709404991500,"reTweetCount":12,"reTweeted":false,"createdDate":"Wed Jul 31 16:12:31 UTC 2013","user":{"location":"India","userId":17710740,"screenName":"dna","userName":"dna","profileDescription":"We are India’s favourite English daily delivering news, views & …Run Code Online (Sandbox Code Playgroud) 我正在使用Hibernate和Spring 3.0我试图将值保存到数据库中但是当我看到一个控制台时,唯一的选择查询显示插入或更新未显示且保存不起作用
我创建了一个sessionFactory bean并将其注入Impl
<bean id="GetStartedDAOBean" class="com.sample.dao.impl.GetStartedDAOImpl" >
<property name="sessionfactory" ref="sessionFactory">
</property>
</bean
<bean id="GetStartedActionBean" class="com.sample.action.GetStartedAction">
<property name="getStartedDAOImpl" ref="GetStartedDAOBean"></property>
<property name="industryDAOImpl" ref="IndustryDAOBean"></property>
<property name="stateDAOImpl" ref="stateDAOBean"></property>
</bean>
Run Code Online (Sandbox Code Playgroud)
在impl我有
private SessionFactory sessionfactory;
public void setSessionfactory(SessionFactory sessionfactory) {
this.sessionfactory = sessionfactory;
}
public void save(Customer customer)throws IllegalStateException,SystemException{
try {
sessionfactory.openSession().saveOrUpdate(customer);
}
catch(Exception e){
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
当我调试sessionFactory中有值但它不保存任何值.并且也不显示任何插入的查询.没有错误.
任何人都可以帮助我吗?
我正在使用spring mvc.在我登录时设置会话属性.我在用户登录时有一个搜索页面,他可以获得有关用户的更多详细信息.没有登录意味着他只能为此目的获得有限的细节我在登录表单中的@SessionAttributes中设置会话对象,并且在用户搜索表单创建中我检查了会话属性是否具有值,如果不是意味着设置默认值.但是当我提交表单时,它会显示错误的HTTP状态
500 - Expected session attribute
@RequestMapping(value = "/user-search", method = RequestMethod.GET)
public String initUserSearchForm(Model model) {
User user = new User();
model.addAttribute("User", user);
if(!model.containsAttribute("userObject"))
model.addAttribute(createDefaultUserCredntials());
return "user";
}
@RequestMapping(value = "/user-byName", method = RequestMethod.GET)
public
@ResponseBody
String getUserByName(HttpServletRequest request,@ModelAttribute("userObject")User user) {
....
....
}
Run Code Online (Sandbox Code Playgroud)
错误是
org.springframework.web.HttpSessionRequiredException: Expected session attribute 'userObject'
org.springframework.web.method.annotation.ModelFactory.initModel(ModelFactory.java:103)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:723)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:687)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:915)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:811)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
Run Code Online (Sandbox Code Playgroud) 我在struts 2中使用struts2-jquery-plugin-3.5.1-sources.jar我将jar文件放在lib目录中,我也将它添加到了buildpath中.我在jsp中创建了一个条目
<%@ taglib prefix="sj" uri="/struts2-jquery-tags" %>
Run Code Online (Sandbox Code Playgroud)
但它显示错误 Can not find the tag library descriptor for "/struts2-jquery-tags"
当我运行它显示的应用程序时
SEVERE: Exception starting filter struts2
Unable to load bean: type:org.apache.struts2.views.TagLibrary class:com.jgeppert.struts2.jquery.views.JqueryTagLibrary - bean - jar:file:/D:/eclipse-indigo/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/Fundation/WEB-INF/lib/struts2-jquery-plugin-3.5.1-sources.jar!/struts-plugin.xml:27:125
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:208)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:131)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452)
at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:205)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4071)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4725)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
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) …Run Code Online (Sandbox Code Playgroud)