这是我正在阅读的书中的示例代码:
ob_start();
include("{$path}.ini");
$string = ob_get_contents();
ob_end_clean();
$pairs = parse_ini_string($string);
Run Code Online (Sandbox Code Playgroud)
我的问题是,如何ob_get_contents()知道从哪里获取内容?({$ path} .ini在这种情况下)?
这是我的web.xml:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet>
<url-pattern>/*</url-pattern>
</servlet-mapping>
Run Code Online (Sandbox Code Playgroud)
当我导航到:
http://localhost:8080/LearningRoot/index.xhtml
Run Code Online (Sandbox Code Playgroud)
我可以看到页面很好,但是当我导航到:
http://localhost:8080/LearningRoot/
Run Code Online (Sandbox Code Playgroud)
我收到错误:
发生错误:
FacesServlet不能具有/*的url模式.请定义一个不同的url模式.
但为什么?
这是我的欢迎档案:
<welcome-file-list>
<welcome-file>/index.xhtml</welcome-file>
</welcome-file-list>
Run Code Online (Sandbox Code Playgroud) 我的Windows 7机器上有IntelliJ Idea 12和Jetty 9.
我还有一个示例JSF项目,它在Tomcat 7.0上运行良好.当我尝试使用Jetty添加运行时,我收到错误:
找到重复的配置文件路径
当我删除
等\码头,jmx.xml
从这个屏幕上的Jetty服务器设置,我没有得到这个错误但是当我尝试启动项目时,我得到:
2013-03-27 17:50:42.076:警告:oejx.XmlParser:main:FATAL @ file:/ D:/Jetty-9/start.d/ line:1 col:1:org.xml.sax.SAXParseException; systemId:file:/ D:/Jetty-9/start.d/; lineNumber:1; columnNumber:1; 序言中不能有内容.Sun.reflect.DeativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)的java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Method.java:601)atg.eclipse.jetty.Mart.invokeMain(Main.java:453)org.eclipse.jetty.start.Main.start(Main. java:595)atg.eclipse.jetty.start.Main.main(Main.java:96)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:601)at com.intellij.rt.execution.application.AppMain.main(AppMain.java) :120)引起:org.xml.sax.SAXParseException; systemId:file:/ D:/Jetty-9/start.d/; lineNumber:1; columnNumber:1; 序言中不能有内容.at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:441)at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368) at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1388)at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl $ PrologDriver.next(XMLDocumentScannerImpl.java: 996)at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java: 116)at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488)at com.sun.org.apache.xerces.in 在com.sun.org.apache.xerces的com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)中的ternal.parsers.XML11Configuration.parse(XML11Configuration.java:835). internal.sparsers.XMLParser.parse(XMLParser.java:123)位于com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210)的com.sun.org.apache.xerces. internal.jaxp.SAXParserImpl $ JAXPSAXParser.parse(SAXParserImpl.java:568)位于org.eclipse.jetty.xml的com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:302).位于org.eclipse.jetty.xml.XmlConfiguration.(XmlConfiguration.java:138)的org.eclipse.jetty.xml.XmlParser.parse(XmlParser.java:220)中的XmlParser.parse(XmlParser.java:204). eclipse.jetty.xml.XmlConfiguration $ 1.run(XmlConfiguration.java:1209)位于org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1160)的java.security.AccessController.doPrivileged(Native Method)中..还有12个
用法:java -jar start.jar [options] [properties] [configs] java -jar start.jar --help#获取更多信息
那么,如何在IntelliJ 12上正确配置Jetty?
我有这个代码:
section .bss
buff resb 1
readfromkeyboard:
mov eax,3 ;specify system read
mov ebx,0 ;specify standard in -> keyboard
mov ecx,buff ;where to store what is read
mov edx,1 ;read 1 byte
int 0x80 ;tell linux to do everything above
mov eax,4 ;sys_write
mov ebx,1 ;Standard output
mov ecx,buff ;what to print
mov edx,1 ;how long to print
int 0x80 ;tell linux to do everything above
Run Code Online (Sandbox Code Playgroud)
哪个工作正常.
当我开始该过程时,光标将开始在终端中闪烁,我可以自由输入字符.此时我可以自由输入任意数量的字符,除非我点击"ENTER",将读取1个字节并将其打印在终端中.
我的问题是,当我输入字符并且点击时,内部发生了什么Enter.所以我在键盘上点击'a',然后说'c',此时数据存储在哪里?它们是否已经在我的代码中由'buff'处理的内存空间中?为什么Linux在我点击时会读取Enter?
我有一个这样的示例代码:
ConnectionPool.dataSource = (DataSource) initialContext.lookup("java:comp/env/jdbc/murach");
Run Code Online (Sandbox Code Playgroud)
在webapp/META-INF/context.xml中
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource name="jdbc/murach"
auth="Container"
type="javax.sql.DataSource"
username="root"
--- Rest of the text ---/>
</Context>
Run Code Online (Sandbox Code Playgroud)
当我将这个Web应用程序部署到Tomcat时,数据库连接很好,但是当我使用Jetty插件尝试使用Jetty时:jetty:run-war
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.1.v20140609</version>
<configuration>
<scanIntervalSeconds>2</scanIntervalSeconds>
<httpConnector>
<port>8082</port>
</httpConnector>
<webApp>
<contextPath>/</contextPath>
</webApp>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我正进入(状态:
javax.naming.NameNotFoundException; remaining name 'jdbc/murach'
Run Code Online (Sandbox Code Playgroud)
我怎么能用码头做这个呢?
我也尝试过添加
<resource-ref>
<description>murach</description>
<res-ref-name>jdbc/murach</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Run Code Online (Sandbox Code Playgroud)
到web.xml,但现在我得到:
java.lang.IllegalStateException: Nothing to bind for name javax.sql.DataSource/default
Run Code Online (Sandbox Code Playgroud) 这是我的代码:
public enum Modification {
NONE, SET, REMOVE;
}
boolean foo(){
for (S s : sList) {
final Modification modification = s.getModification();
switch (modification) {
case SET:
case REMOVE:
return true;
/*
case NONE:
break;
*/
}
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
当代码如上所示时,IntelliJ会说:
'for'语句不会循环更少...()报告其机构保证最多执行一次的for,while和do语句的任何实例.通常,这是一个错误的指示.
只有当我做出以下更改时,IntelliJ才会满意:
for (S s : sList) {
final Modification modification = s.getModification();
switch (modification) {
case SET:
case REMOVE:
return true;
case NONE:
break;
}
}
Run Code Online (Sandbox Code Playgroud)
如果case NONE: 不包含在switch语句中,为什么我的for循环不循环?
这段代码来自我们的项目,生产代码:
if (changedToNull) {
try {
throw new Exception();
} catch (Exception e) {
log.debug("changedToNull", e);
}
}
Run Code Online (Sandbox Code Playgroud)
开发人员不再与我们合作.
为什么有人会抛出Exception并直接捕获并记录它?
我试图在Pandas中一起使用groupby,nlargest和sum功能,但是无法使它工作.
State County Population
Alabama a 100
Alabama b 50
Alabama c 40
Alabama d 5
Alabama e 1
...
Wyoming a.51 180
Wyoming b.51 150
Wyoming c.51 56
Wyoming d.51 5
Run Code Online (Sandbox Code Playgroud)
我想用groupby州选择,然后按人口排名前2个县.然后只使用前2个县人口数来获得该州的总和.
最后,我将有一个列表,其中包含州和人口(前2个县).
我可以得到groupby并且nlargest工作,但获得总和nlargest(2)是一个挑战.
我现在的路线很简单: df.groupby('State')['Population'].nlargest(2)
当我从命令行输入git pull时,我可以毫无问题地获取代码.
当我打开SourceTree for Windows,并尝试拉,我得到:
git -c diff.mnemonicprefix=false -c core.quotepath=false fetch origin
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Completed with errors, see above.
Run Code Online (Sandbox Code Playgroud)
我可能做错了什么?
当我们说我们有一个"数据库连接"或"有几个连接打开的连接池"时,在技术层面,我们究竟意味着什么?
我的理解是:
数据库连接是指在数据库进程中运行的线程的链接,该线程被阻塞并等待另一个进程中另一个线程的输入.
这是正确的定义吗?
因此,当我在计算机中运行mysql和在其他计算机(或同一台计算机上运行,并不重要......)的Java应用程序时,当我执行类似的操作时:
conn.open();
Run Code Online (Sandbox Code Playgroud)
打开数据库连接..
mysql进程是否会为我创建一个新线程并阻止该线程并开始侦听输入?
客户端怎么样?如果我不关闭连接会怎么样?