我有1个表单,有2个提交按钮.
当我单击一个按钮时,我希望发布某些值.当我点击其他按钮时,我希望发布其他值.
这是我试过的,没用的:
<form action="/test" method="post">
<input type="hidden" id="bool" name="bool" value="" />
<input type="submit" value="Yes" onclick="test()" />
<input type="submit" value="No" onclick="test1()" />
</form>
<script type="text/javascript">
function test() {
document.getElementById('bool').value = "true";
}
function test1() {
document.getElementById('bool').value = "false";
}
</script>
Run Code Online (Sandbox Code Playgroud) 我有一个spring项目并使用ANT将我的战争编译/部署到Tomcat.所以基本上它只是创建一个war文件并将其移动到tomcat文件夹.
文件夹结构是这样的:
Spring
-src
ALL MY SRC (JAVA) files
-war
-WEB-INF
-jsp
-lib
ALL MY LIBRARIES
-properties
web.xml
spring-servlet.xml
-META-INF
build.xml
pom.xml // putting my pom.xml here
Run Code Online (Sandbox Code Playgroud)
使用ant我手动下载所有库.现在看来,由于pom.xml,maven会自动下载所有库.问题/问题:
WEB-INF/lib?怎么样?几乎没有问题,因为我从未使用过maven.
此代码导致编译时错误:
#include <iostream>
#include <vector>
#include <cmath>
template <unsigned short n>
class Vector {
public:
std::vector<float> coords;
Vector();
Vector(std::vector<float> crds);
float distanceFrom(Vector<n> v);
template <unsigned short m>
friend std::ostream& operator <<(std::ostream& out, const Vector<m>& v);
};
template <unsigned short n>
Vector<n>(vector<float> crds) { // HERE IS ERRRO
}
Run Code Online (Sandbox Code Playgroud)
编译错误:
C:\CodeBlocks\kool\praks3\vector.h|29|error: expected ')' before '<' token|
||=== Build finished: 1 errors, 0 warnings ===|
Run Code Online (Sandbox Code Playgroud) 当我将鼠标移到椭圆上时,我想改变椭圆的颜色.但是我没有找到任何来自Qt Creator的引用和自动完成的东西.
你们知道怎么做吗?
我的一些代码:
void DrawingWidget::paintEvent(QPaintEvent *event) {
QPainter painter(this);
painter.fillRect(event->rect(), Qt::white);
for(int i = 0; i < pointList.size(); i++) {
if (pointList[i].x() >= 0 && pointList[i].y() >= 0)
painter.drawEllipse(pointList[i], 10, 10);
}
painter.drawLines(lineList);
m_mainWindow->updateCount();
}
Run Code Online (Sandbox Code Playgroud)
鼠标按事件处理程序:
void DrawingWidget::mousePressEvent(QMouseEvent *event) {
if (event->button() == Qt::LeftButton
&& event->buttons() == Qt::LeftButton) {
// DO STUFFF
}
}
Run Code Online (Sandbox Code Playgroud)
鼠标移动事件处理程序
void DrawingWidget::mouseMoveEvent(QMouseEvent *event) {
if (m_mainWindow->getSelectedTool() == MainWindow::moveVertexTool) {
m_x = event->x();
m_y = event->y();
if (isPointNear(m_x, m_y)) {
//STUFF
}
update();
}
} …Run Code Online (Sandbox Code Playgroud) 我的javascript文件:
var ms = 3000;
$.get("curl.php", { test: ms } );
Run Code Online (Sandbox Code Playgroud)
我的curl.php:
$ms = $_GET("test");
echo $ms;
Run Code Online (Sandbox Code Playgroud)
Firefox firebug说:
致命错误:函数名称必须是第2行的C:\ Users\Jansu\Documents\workspace\php\curl.php中的字符串
可能是什么问题呢?
更好的是当javascript和php代码在同一个文件中时,所以我不必发布/得到任何东西.只是以某种方式将javascript传递给php.
主cpp文件:
#include <iostream>
#include <cstdio>
#include "table.h"
using namespace std;
int main() {
Table test;
int i;
for(i = 0; i < 26; i++) {
cout << test.start[2] << endl;
}
system("PAUSE");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
头文件:
#pragma once
class Table {
public:
char start[26];
Table();
Table(char key[26]);
~Table();
};
Run Code Online (Sandbox Code Playgroud)
cpp文件:
#include "table.h"
Table::Table() {
char start[26] = "ABCDEFGHIJKLMNOPRSTUVWXYZ";
}
Table::Table(char key[26]) {
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误:
1>playfair.obj : error LNK2019: unresolved external symbol "public: __thiscall Table::~Table(void)" (??1Table@@QAE@XZ) referenced in function _main
1>c:\Users\Jansu\Documents\Visual …Run Code Online (Sandbox Code Playgroud) bool choose() {
int answer = 0;
while(answer != 1 || answer != 2) {
cout << endl << "Do you want to encrypt(enter 1) or decrypt(enter 2)?" << endl;
cin >> answer;
}
if(answer == 1) return true;
return false;
}
Run Code Online (Sandbox Code Playgroud)
从行读取并将输入与整数进行比较的最佳方法是什么?我知道的方式cin,gets,getline(cin, answer).我应该使用哪个以及为什么?
目前,这种方式不起作用,因为当我输入1或2时,它仍然存在while.
我的代码:
var test = "aa";
test += "ee";
alert(test);
Run Code Online (Sandbox Code Playgroud)
打印出"aaee"
我怎么能做同样的事情,但添加字符串不是结束,但开始:像这样:
var test = "aa";
test = "ee" + test;
Run Code Online (Sandbox Code Playgroud)
这是漫长的道路,但是在第一个例子中是否有一些较短的方式?
我想要的是我不能在定义中再次写出初始变量.
public static string GetFoo() {
string source = GameInfoUtil.GetSource(repairRequest, () => {
return "0"; // this line gives error
});
.
.
MORE WORK, BUT WANT TO SKIP IT
}
public static string GetSource(WebRequest request, Action failureCallback) {
// DOING WORK HERE WITH REQUEST
if(WORK IS SUCCESSFULL) RETURN CORRECT STRING ELSE CALL ->
failureCallback();
return "";
}
Run Code Online (Sandbox Code Playgroud)
我想做这样的事情,但它给了我错误:
Error 2 Cannot convert lambda expression to delegate type 'System.Action' because some of the return types in the block are not implicitly …Run Code Online (Sandbox Code Playgroud) 我有这个正则表达式:
<a href(.*foo.bar.*)a>
Run Code Online (Sandbox Code Playgroud)
对于这个字符串,它只给我一个匹配,但我需要它给3个匹配.
<a href="https://foo.bar/1">First</a> RANDOM TEXT COULD BE HERE <a href="https://foo.bar/2">Second</a> RANDOM TEXT COULD BE HERE <a href="https://foo.bar/3">Third</a>
Run Code Online (Sandbox Code Playgroud)
所以每个都a href应该是个体的.
我怎么能做到这一点?
编辑:
此代码搜索匹配项:
Pattern pattern = Pattern.compile("<a href(.*foo.bar.*)a>");
Matcher matcher = pattern.matcher(body);
List<String> matches = new ArrayList<String>();
while (matcher.find()) {
matches.add(matcher.group());
}
Run Code Online (Sandbox Code Playgroud)