我需要使用具有不同url模式的单个servlet.我给tomcat服务器尝试如下所示.但我想知道真正的编码标准,请帮帮我吗?
String servletPath = request.getServletPath();
if("/HelloServletone".equalsIgnoreCase(servletPath))
{
System.err.println("1?*");
///logic move to controller one
}
if("/HelloServlettwo".equalsIgnoreCase(servletPath))
{
System.err.println("2*");
///logic move to controller two
}
Run Code Online (Sandbox Code Playgroud)
web.xml中
<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/HelloServletone</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/HelloServlettwo</url-pattern>
</servlet-mapping>
Run Code Online (Sandbox Code Playgroud)
JSP1:
<form method="post" action="HelloServletone">
//getting inputs and move to servlet
<input type="submit" value="login " />
Run Code Online (Sandbox Code Playgroud)
jsp2:
<form method="post" action="HelloServlettwo">
//getting inputs and move to servlet
Run Code Online (Sandbox Code Playgroud)
Document document = new Document(reader.getPageSizeWithRotation(1));
PdfCopy writer = new PdfCopy(document, new FileOutputStream(outFile));
document.open();
PdfImportedPage page = writer.getImportedPage(reader, ++i);
writer.setFullCompression();
writer.addPage(page);
document.close();
writer.close();
Run Code Online (Sandbox Code Playgroud)
我正在使用iText来拆分和合并PDF,我需要你的帮助以编程方式减少(压缩)输出PDF大小.请让我知道实现相同目标的步骤.
我需要从另一个模式内部引用这个学生模式:
{
"type": "record",
"namespace": "data.add",
"name": "Student",
"fields": [
{
"name": "Name",
"type": "string"
},
{
"name": "Age",
"type": "int"
}
]
}
Run Code Online (Sandbox Code Playgroud)
这是需要引用Student 的父地址架构:
{
"type": "record",
"namespace": "data.add",
"name": "Address",
"fields": [
{
"name": "student",
"type": "Student"
}
]
}
Run Code Online (Sandbox Code Playgroud)
当我使用 Gradle 和 Avro 插件构建时,上面的内容会引发错误。两个架构都位于同一文件夹中。
public class CalendarCal {
public static void main(String[] args) {
Date date = new Date();
SimpleDateFormat simpleDateformat = new SimpleDateFormat("yy");
String m = simpleDateformat.format(date);
System.out.println("Year:" + m);
int year = Calendar.getInstance().get(Calendar.YEAR) % 100;
System.err.println(year);
}
}
Run Code Online (Sandbox Code Playgroud)
我可以从中检索当前年份.如何在实用程序的帮助下获得最后一个(上一年)?我不想做像这样的计算currentyear - 1.
我正在使用下面的代码在新窗口中打开页面,其按预期工作,但是当我右键单击“在新选项卡中打开”时,它会被“about:blank#blocked”阻止,我希望链接在新标签如何解决?
<a href="javascript:;" style="color:red;" onclick="window.open('http://www.la.unm.edu',null,'left=50,top=50,width=700,height=500,toolbar=1,location=0,resizable=1,scrollbars=1'); return false;">Limk</a>Run Code Online (Sandbox Code Playgroud)
如何从java脚本重定向到struts动作?
如果脚本中的条件成功,那么我需要在config xml中调用一个动作,否则调用控件的动作不需要保持在同一页面?请帮忙吗?
Java脚本
function displayDate()
{
var x=document.getElementsByName("userName")
if(x = "shan")
{
alert("shankarasd");
document.myForm.action ="/setUpForInsertOrUpdate";
document.myForm.submit();
}
}
Run Code Online (Sandbox Code Playgroud)
HTML
<html>
<body>
<s:form action="HelloWorld" >
<s:textfield name="userName" label="User Name" />
<s:submit onclick="displayDate()" />
</s:form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
config.xml中
<struts>
<package name="default" extends="struts-default">
<action name="HelloWorld" class="vaannila.HelloWorld.HelloWorld">
<result name="SUCCESS">/success.jsp</result>
</action>
<action name="setUpForInsertOrUpdate" method="setUpForInsertOrUpdate" class="vaannila.HelloWorld.HelloWorld">
<result name="SUCCESS1">/success1.jsp</result>
</action>
<action name="back" method="back" class="vaannila.HelloWorld.HelloWorld">
<result name="SUCCESS2">/success.jsp</result>
</action>
</package>
</struts>
Run Code Online (Sandbox Code Playgroud) 当我将项目转换为runnable jar相同的系统时,图像将在输出中加载.但是当我在另一个系统中尝试时,图像无法加载?如何提供图片网址,而不是使用c:?请帮忙吗?
JToolBar toolbar = new JToolBar("Toolbar", JToolBar.HORIZONTAL);
JButton capturebut = new JButton(new ImageIcon("C:\\sampleprojects\\
compare\\shankar\\src\\capture.gif"));
capturebut.setToolTipText("Capture");
toolbar.add(capturebut);
Run Code Online (Sandbox Code Playgroud) 我试图找到今天前 7 天的日期。
CURRENT_DT=`date +"%F %T"`
diff=$CURRENT_DT-7
echo $diff
Run Code Online (Sandbox Code Playgroud)
我正在尝试像上面这样的东西来找到比当前日期少 7 天的时间。有人可以帮我吗?
我们如何使用多线程将多个文件追加到单个文件中,我的每个文件都有10M的行。所以我想同时处理所有文件?
#!/bin/bash
appendFiles A.TXT &
appendFiles B.TXT &
appendFiles C.TXT &
wait
function appendFiles
{
while read -r line; do
echo $line >>final.txt
done < $1
}
Run Code Online (Sandbox Code Playgroud) awk -F, '
{
printf(" Code %s %s\n",$1,$2)
r[NR] = $1
c[NR] = $3
}
END { for(i = 1; i <= NR; i++) printf(" %s Record Count %s\n", r[i],c[i])
}' totalsum.txt
Run Code Online (Sandbox Code Playgroud)
这是我的输入文件
17,123456,1
16,1234,2
0211,34567,2
21,2345,2
Run Code Online (Sandbox Code Playgroud)
我得到如下的输出.,
Code 17 123456
Code 16 1234
Code 0211 34567
Code 21 2345
17 Record Count 1
16 Record Count 2
0211 Record Count 2
21 Record Count 2
Run Code Online (Sandbox Code Playgroud)
我需要格式化输出,如.,下面表示值,
Code 16 1,234
Code 0211 34,567
Code 21 112,345
17 Record Count 1 …Run Code Online (Sandbox Code Playgroud)