小编jcr*_*kar的帖子

如何使用具有不同url模式的单个Servlet?

我需要使用具有不同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)

jsp servlets

11
推荐指数
1
解决办法
2万
查看次数

如何在Java中以编程方式减少PDF文件大小?

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大小.请让我知道实现相同目标的步骤.

java pdf itext

10
推荐指数
2
解决办法
2万
查看次数

如何在另一个 avro 架构中引用一个 avro 架构

我需要从另一个模式内部引用这个学生模式:

{
  "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 插件构建时,上面的内容会引发错误。两个架构都位于同一文件夹中。

avro avsc

8
推荐指数
1
解决办法
1万
查看次数

如何从java当年的结果获得前一年?

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.

java

5
推荐指数
1
解决办法
3万
查看次数

如何避免打开新选项卡时出现空白被阻塞的情况

我正在使用下面的代码在新窗口中打开页面,其按预期工作,但是当我右键单击“在新选项卡中打开”时,它会被“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)

javascript url window.open

5
推荐指数
1
解决办法
4万
查看次数

如何从struts 2中的java脚本重定向到struts动作?

如何从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)

javascript struts2

4
推荐指数
1
解决办法
2万
查看次数

如何在java runnable jar中加载图像?

当我将项目转换为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)

java icons swing

3
推荐指数
1
解决办法
3161
查看次数

如何在 Unix 中找到减去 7 天的当前日期?

我试图找到今天前 7 天的日期。

 CURRENT_DT=`date +"%F %T"`
 diff=$CURRENT_DT-7 
 echo $diff 
Run Code Online (Sandbox Code Playgroud)

我正在尝试像上面这样的东西来找到比当前日期少 7 天的时间。有人可以帮我吗?

unix ksh sh

3
推荐指数
1
解决办法
1万
查看次数

如何在shell脚本中格式化日期

如何在shell脚本中格式化"2011-09-01"格式的日期"01-SEP-2011"?

bash shell

1
推荐指数
1
解决办法
1616
查看次数

如何在bash中使用多线程附加多个文件

我们如何使用多线程将多个文件追加到单个文件中,我的每个文件都有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)

unix bash shell sh

1
推荐指数
1
解决办法
69
查看次数

在shell/awk中使用数千个分隔符格式化数字

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)

awk sh

0
推荐指数
1
解决办法
1827
查看次数

标签 统计

java ×3

sh ×3

bash ×2

javascript ×2

shell ×2

unix ×2

avro ×1

avsc ×1

awk ×1

icons ×1

itext ×1

jsp ×1

ksh ×1

pdf ×1

servlets ×1

struts2 ×1

swing ×1

url ×1

window.open ×1